Esempio n. 1
0
        public async Task <bool> Login(LoginViewModel model)
        {
            var person = _db.Users.Where(x => x.UserName == model.Email &&
                                         !x.IsDeleted &&
                                         x.Status == StatusEnum.Active &&
                                         x.Profile == ProfileEnum.Superuser).FirstOrDefault();

            if (person == null)
            {
                return(false);
            }

            var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, false);

            switch (result)
            {
            case SignInStatus.Success:
                var user = _db.Users.FirstOrDefault(x => x.UserName == model.Email && x.Profile == ProfileEnum.Superuser);
                if (user != null)
                {
                    LogService.AdministrationLogs(SystemLog.LogIn, _db, user.Id);
                }

                return(true);

            default:
                return(false);
            }
        }
Esempio n. 2
0
        public bool Logoff(LoginViewModel model)
        {
            var ctx         = Request.GetOwinContext();
            var authManager = ctx.Authentication;

            var user = Person.GetLoggedPerson(User);

            if (user != null)
            {
                LogService.AdministrationLogs(SystemLog.LogOut, _db, user.Id);
            }

            authManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie);
            return(true);
        }