New created user with role "Authenticated user" can login to admin panel of site. Why?
How restrict all users, except admin, to login to admin panel?
Are both 'Administrator' and 'Authenticated user' ticked in the 'Roles' section of the 'Edit User' page in the admin?
That is all I can think of as I have never experienced this before.
No, new registered user is ticked only as 'Authenticated user'.
I think it is a bug and can be fixed in Login.aspx.cs in the following finction:
private void btnLogin_Click(object sender, System.EventArgs e)
{
AuthenticationModule am = (AuthenticationModule)this.Context.ApplicationInstance.Modules["AuthenticationModule"];
if (am.AuthenticateUser(txtUsername.Text, txtPassword.Text, false) && this.User.IsInRole("Administrator"))
{
Context.Response.Redirect(FormsAuthentication.GetRedirectUrl(this.User.Identity.Name, false));
}
else
{
this.lblError.Text = "Invalid username or password.";
this.lblError.Visible = true;
}
}
The Red code is FIX of the bug.
Is it correct method or not?
No, this is not correct. The login page is also used sometimes for front-end pages.
Please check the permissions on your site. The admin pages inherit from AdminBasePage and only roles with AccessLevel Administrator should be able to access these pages. Probably, the Authenticated User role has a little bit too much rights.
Here is the scenario:
1. Anonymus registering on my site via User module
2. After registration he got an email with password (via admin panel I can see his role - only 'Authenticated user' is checked, Editor and Administrator is blank)
3. New registered user go to
http://mysite/admin page enter his username and password and granted access to admin panel
What is wrong with my permissions in this scenario?
Go to 'Manage roles' and check the permissions for the Authenticated user roles. Only 'Authenticated' should be checked and 'Administrator' certainly not.