Exemple #1
0
 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);
 }
Exemple #2
0
        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);
            }
        }
Exemple #3
0
        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);
        }