public static bool logoff() { if (Academico.isAutenticado()) { //authentica System.Web.Security.FormsAuthentication.SignOut(); //grava academico no session HttpContext.Current.Session["Id"] = null; HttpContext.Current.Session["PrimeiroNome"] = null; HttpContext.Current.Session["SegundoNome"] = null; return(true); } return(false); }
public static string getIdNome() { try { string n1 = HttpContext.Current.Session["PrimeiroNome"].ToString(); string n2 = HttpContext.Current.Session["SegundoNome"].ToString(); return(n1 + " " + n2); } catch (Exception) { Academico.logoff(); return(null); } }
public static bool autenticar(Unitunes.Models.Academico academico) { if (Academico.isAcademicoExists(academico)) { //authentica System.Web.Security.FormsAuthentication.SetAuthCookie(academico.Email, false); //grava academico no session var ctx = new dbEntities(); var login = ctx.AcademicoSet; var existeUsuario = from u in login where u.Email == academico.Email & u.Password == academico.Password select u; if (existeUsuario.Count() > 0) { HttpContext.Current.Session["Id"] = existeUsuario.First().Id; HttpContext.Current.Session["PrimeiroNome"] = existeUsuario.First().PrimeiroNome; HttpContext.Current.Session["SegundoNome"] = existeUsuario.First().SegundoNome; } return(true); } return(false); }