Exemplo n.º 1
0
        protected void Application_PostAuthenticateRequest(Object sender, EventArgs e)
        {
            if (FormsAuthentication.CookiesSupported == true)
            {
                try
                {
                    //lets take out the username now
                    string username = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name;
                    string roles    = string.Empty;

                    using (SisparkModel db = new SisparkModel())
                    {
                        User user = db.User.SingleOrDefault(u => u.Usuario == username);

                        roles = user.Usertype.description;
                    }

                    //let us extract the roles from our own custom cookie

                    //Let us set the Principal with our user specific details

                    HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(
                        new System.Security.Principal.GenericIdentity(username, "Forms"), roles.Split(','));
                }
                catch (Exception)
                {
                    //something went wrong
                }
            }
        }
Exemplo n.º 2
0
        public static void GuardarLogInLog(User user)
        {
            using (var db = new SisparkModel())
            {
                var sysUserLog = db.UserLog.Create();
                sysUserLog.UserId     = user.UserId;
                sysUserLog.FechaYHora = DateTime.Now;
                sysUserLog.Accion     = "Login";

                db.UserLog.Add(sysUserLog);
                db.SaveChanges();
            }
        }
Exemplo n.º 3
0
        public static void GuardarLogOutLog(string LoggedUser)
        {
            using (var db = new SisparkModel())
            {
                var user       = db.User.FirstOrDefault(u => u.Usuario == LoggedUser);
                var sysUserLog = db.UserLog.Create();
                sysUserLog.UserId     = user.UserId;
                sysUserLog.FechaYHora = DateTime.Now;
                sysUserLog.Accion     = "Logout";

                db.UserLog.Add(sysUserLog);
                db.SaveChanges();
            }
        }
Exemplo n.º 4
0
        public static void GuardarCancelado(string Logged, Ticket ticket)
        {
            using (var db = new SisparkModel())
            {
                var user   = db.User.FirstOrDefault(u => u.Usuario == Logged);
                var TicLog = db.TicketLog.Create();
                TicLog.UserId          = user.UserId;
                TicLog.DateTimeLog     = DateTime.Now;
                TicLog.TransactionType = "Cancelado";
                TicLog.TicketId        = ticket.TicketId;

                db.TicketLog.Add(TicLog);
                db.SaveChanges();
            }
        }