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)); }
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); }
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); }
public UserManager(IHttpContextAccessor _hca) { HCA = _hca; DF = new ApplicationUsersFactory(); }