Beispiel #1
0
        public Task <ResultStatus> DeleteAsync(string id)
        {
            var r = new ResultStatus();

            using (var df = new ApplicationUsersFactory()) {
                var i = df.Delete(id);
                r.IsSuccessful = i > 0;
                if (r.IsSuccessful)
                {
                    r.Message = "The record was successfully deleted.";
                }
            }
            return(Task.FromResult(r));
        }
Beispiel #2
0
        internal static Task SignOutAsync(CookieSigningOutContext context)
        {
            var id = context.HttpContext.User.Identity.Name;

            using (var df = new ApplicationUsersFactory()) {
                var usr = df.GetUser(id);
                if (usr != null)
                {
                    usr.IsLogedIn = false;
                    df.Update(usr);
                }
            }
            return(Task.CompletedTask);
        }
Beispiel #3
0
        public static Task ValidateAsync(CookieValidatePrincipalContext context)
        {
            var identity = context.Principal.Identity;

            AllConsts.RPR.RemoveAll(u => u.Expires <= DateTime.UtcNow);
            if (identity?.IsAuthenticated == true)
            {
                using (var df = new ApplicationUsersFactory())
                {
                    var usr = df.GetUserByID(identity.Name);
                    if (usr.IsLogedIn == false || usr.CurrentStatus != AccountStatus.Active)
                    {
                        usr.IsLogedIn = false;
                        context.RejectPrincipal();
                        context.HttpContext.SignOutAsync();
                    }
                    usr.LastActivityDate = DateTime.UtcNow;
                    df.Update(usr);
                }
            }
            return(Task.CompletedTask);
        }
Beispiel #4
0
 public UserManager(IHttpContextAccessor _hca)
 {
     HCA = _hca;
     DF  = new ApplicationUsersFactory();
 }