3
I need to direct the administrator to a location, the first-time student to another and the student who has already accessed, to another.
My validations are working, everything is going well. However, I would like to know if there is a best practice to apply for such:
[HttpPost]
public ActionResult Validar(String cpf, String senha)
{
var bdAluno = CONSUL_CA_AlunoAplicacaoConstrutor.CONSUL_CA_AlunoAplicacaoEF();
var alunos = bdAluno.ListarTodos().Where(x => x.Senha == senha);
if (alunos.Count() == 1)
{
var aluno = alunos.First();
if (aluno.Cpf == "1413914")
{
FormsAuthentication.SetAuthCookie("admin", false);
return RedirectToAction("Index", "HomeADM", new { area = "Administrador" });
}
else if (aluno.Senha == "sbe123") {
FormsAuthentication.SetAuthCookie(aluno.Cpf, false);
return RedirectToAction("AlterarSenha", "HomeAL", new { area = "Aluno" });
}
else {
FormsAuthentication.SetAuthCookie(aluno.Cpf, false);
return RedirectToAction("Index", "HomeAL", new { area = "Aluno" });
}
}
return RedirectToAction("Index");
}