Good afternoon guys, I need your help.
I have two access profiles to my system. "Master-IT" and "Developer"
This is my system login controller
[HttpPost]
public ActionResult Index(Usuario usr)
{
if (ModelState.IsValid)
{
usr = _usuarioService.GetUsuarioCentroNaoRemovido(usr.Email, usr.Senha);
if (usr != null)
{
if (usr.Removido == 1)
{
var hhospitais = _hospitalService.GetAll().Select(s => new { HosppitalId = s.CentroId, Descricao = $"{s.CentroId} - {s.Nome}" });
ViewBag.Hospitais = new SelectList(hhospitais, "HospitalId", "Descricao", "0");
ModelState.AddModelError("UserNotFound", "Usuário bloqueado.");
return View();
}
var hospitaisLista = UsuarioCentroService.GetUsuarioCentrosByUsuario(usr.UsuarioId);
usr.Centros = hospitaisLista.ToList();
var permissoes = _permissoesService.GetPermissaoByUser(usr.UsuarioId).Select(s => s.Nome).ToList();
CriarCookie(usr);
CreateTicket(usr, permissoes);
_usuarioService.Dispose();
return RedirectToAction("Index", "Cadastro", new { area = "Formulario" });
}
}
var hospitais = _hospitalService.GetAll().Select(s => new { HospitalId = s.CentroId, Descricao = $"{s.CentroId} - {s.Nome}" });
ViewBag.Hospitais = new SelectList(hospitais, "HospitalId", "Descricao", "0");
ModelState.AddModelError("UserNotFound", "Usuario não encontrado!");
return View();
}
My request for help is as follows, I need to check which profile you are accessing
If Master-TI enters this view return RedirectToAction("Index", "Cadastro", new { area = "Formulario" });
If Developer enters this view return RedirectToAction("Desenvolvimento", "Cadastro", new { area = "Formulario" });
I tried to use the User.IsInRole ("Master-TI") doing an if on return only that did not work