1
Based on my previous question: Problem with page return according to C profile# When accessing the system with another user with the "ADMIN" Profile, the controller’s return does not fall into the view and does not call the route of the page that should return. Already accessing with the "System Administrator" works. What might be going on ?
public ActionResult LogOn(FormCollection f, string returnUrl)
{
Conta user = new Conta();
ContaModels atrrConta = new ContaModels();
atrrConta = user.RetornaUser(f["login"]);
if (user.AutenticaUser(atrrConta, f["senha"]))
{
//Rotina para autenticar usuario
if (returnUrl == "" || returnUrl == null)
{
returnUrl = "../CalendarioAlertaSMS";
}
System.Web.Security.FormsAuthentication.SetAuthCookie(f["login"], false);
Session["PERFIL"] = atrrConta.Ide_Perfil;
if (Session["PERFIL"].ToString() == "ADMIN")
{
returnUrl = "../PainelAdm";
}
return Redirect(returnUrl);
}
else {
ViewBag.Message = "Login ou senha inválidos.";
return View();
}
}
You have two profiles, "Admin" and "System Administrator", that’s right?
– Leonel Sanches da Silva
@Gypsy Morrison Mendez I have an admin user and another normal one, only with the administrator profile. In the case is equal, only changes the user name.
– AndreeH
You can put here in your question the updated code?
– Leonel Sanches da Silva
I had opened another forum where I posted it. But I will put again, I .. :)
– AndreeH
Pronto Cigano ..
– AndreeH
SetAuthCookie
should not be the first instruction within theif
?– Leonel Sanches da Silva
Oh type, when I access with the admin user who has the admin profile works well, it returns the right page that in the case is this ".. /Paineladm". Then I changed the profile of a user and put him as admin, with this was to return this page too and does not return. I put a breakpoint in the view and when access as administrator it falls in it, but then when access with this user does not fall in it ..
– AndreeH
I tried passing the Setauthcookie first but it still didn’t work ..
– AndreeH
Dude, this new user you’re testing the information that comes from:
atrrConta.Ide_Perfil;
is ADMIN in high box? for if it is not going at all.– Ivan Teles
It’s high cashier yes @Ivanteles. I got it man. Thank you.
– AndreeH
The problem was a Role in a "hidden" location that was allowing access to the page only for Admin user, not users that contained profile "Admin".
– AndreeH