public async Task <CustomResponse <string> > SignOut(SignOutModel model) { var user = await _userManager.FindByNameAsync(model.UserName); var userSession = _context.AspNetUserSessions.FirstOrDefault(t => t.UserId == user.Id && t.Token == model.RefreshToken); #region Validate userSession if (userSession == null) { _infos.Add("User don't have registered session"); return(new CustomResponse <string> { Message = _infos }); } #endregion userSession.Validity = false; _context.Update(userSession); await _context.SaveChangesAsync(); await _signInManager.SignOutAsync(); return(new CustomResponse <string> { Succeed = true }); }
public async Task <RecordResult> SignOut([FromBody] SignOutModel model) { // 从数据库获取签到记录 Record record = await(from r in _context.Records where r.SignOutTime == null && r.StudentId == model.StudentId select r).FirstAsync(); // 签退 record.SignOut(); // 更新签到记录 try { _context.Update(record); await _context.SaveChangesAsync(); } catch (Exception e) { _logger.LogError($"DataBase Error: {e.Message}"); return(RecordResult.Fail(RecordErrorResource.DataBaseError)); } return(RecordResult.Success()); }
public async Task <CustomResponse <string> > SignOut(SignOutModel model) { var infos = new List <string>(); var user = await _userManager.FindByEmailAsync(model.Email); var userSession = _context.AspNetUserSessions.FirstOrDefault(t => t.UserId == user.Id && t.DeviceName == model.UserAgent); if (userSession == null) { infos.Add("User don't have registered session"); return(new CustomResponse <string> { Message = infos }); } userSession.Validity = false; _context.Update(userSession); await _context.SaveChangesAsync(); await _signInManager.SignOutAsync(); return(new CustomResponse <string> { Succeed = true }); }
public async Task SignOutAsync(SignOutModel signOutModel) { var userLogModel = new UserLogModel(signOutModel.Id, LogType.SignOut); await UserLogApplicationService.AddAsync(userLogModel); await UnitOfWork.SaveChangesAsync(); }
public async Task SignOutAsync(SignOutModel signOutModel) { if (signOutModel is null) { throw new ArgumentNullException(nameof(signOutModel)); } var userLogModel = new UserLogModel(signOutModel.Id, LogType.SignOut); await _userLogApplicationService.AddAsync(userLogModel).ConfigureAwait(false); await _unitOfWork.SaveChangesAsync().ConfigureAwait(false); }
public async Task <AuthResponse> SignOut(SignOutModel signOutModel) { var response = default(AuthResponse); var userId = signOutModel.Id; var user = await userManager.FindByIdAsync(userId); if (user == null) { var errors = GetErrorsFromParams("User was not found"); response = AuthResponseError.GetNotFoundError(errors, "Sign out has failed"); } else { await signInManager.SignOutAsync(); response = new AuthResponseOk("Sign out success"); } return(response); }
public async Task <IActionResult> SignOut([FromBody] SignOutModel model) { #region Validate Model var userInputValidated = _signOutModelValidator.Validate(model); if (!userInputValidated.IsValid) { _infos.Add(_badRequest.ShowError(int.Parse(userInputValidated.Errors[0].ErrorMessage)).Message); return(BadRequest(new CustomResponse <string> { Message = _infos })); } #endregion var signedOut = await _myAuthentication.SignOut(model); return(Ok(signedOut)); }
public async Task <IActionResult> SignOutAsync([FromBody] SignOutModel signOutModel) { var authResponse = await authService.SignOut(signOutModel); return(this.GetResponseResult(authResponse)); }
public static UserLogModel Create(SignOutModel signOutModel) { return(new UserLogModel(signOutModel.Id, LogType.SignOut)); }
public async Task SignOutAsync(SignOutModel signOutModel) { await AddUserLogAsync(signOutModel.UserId, LogType.SignOut).ConfigureAwait(false); }
public async Task SignOutAsync(SignOutModel signOutModel) { var addUserLogModel = new AddUserLogModel(signOutModel.UserId, LogType.SignOut); await UserLogApplicationService.AddAsync(addUserLogModel); }
public Task SignOutAsync() { var signOutModel = new SignOutModel(User.Id()); return(UserService.SignOutAsync(signOutModel)); }
public void SignOut() { var signOutModel = new SignOutModel(User.ClaimNameIdentifierValue()); AuthenticationApplication.SignOut(signOutModel); }
public Task SignOutAsync(SignOutModel signOutModel) { return(AuthenticationDomain.SignOutAsync(signOutModel)); }
public void SignOut(SignOutModel signOutModel) { var userLogModel = new UserLogModel(signOutModel.UserId, LogType.Logout); UserLogDomain.Save(userLogModel); }
public Task SignOutAsync(SignOutModel signOutModel) { //var userLogModel = new UserLogModel(signOutModel.Id, LogType.SignOut); return(Task.CompletedTask); }
public async Task SignOutAsync(SignOutModel signOutModel) { var userLogModel = UserLogFactory.Create(signOutModel); await _userLogApplicationService.AddAsync(userLogModel); }
public void SignOut(SignOutModel signOutModel) { AuthenticationDomain.SignOut(signOutModel); }
public void SignOut(SignOutModel signOut) { UserLogDomain.Save(signOut.UserId, LogType.Logout); }
public async Task SignOutAsync(SignOutModel signOutModel) { var userLogModel = new UserLogModel(signOutModel.Id, LogType.SignOut); await _userLogApplicationService.AddAsync(userLogModel); }
public async Task SignOutAsync(SignOutModel signOutModel) { await AddUserLogAsync(signOutModel.UserId, LogType.SignOut); }
public Task SignOutAsync() { var signOutModel = new SignOutModel(SignedInModel.UserId); return(UserApplicationService.SignOutAsync(signOutModel)); }
public Task SignOutAsync(SignOutModel signOutModel) { var userLogModel = new UserLogModel(signOutModel.UserId, LogType.Logout); return(UserLogDomain.SaveAsync(userLogModel)); }
public void SignOut() { var signOutModel = new SignOutModel(User.Id()); AuthenticationApplication.SignOut(signOutModel); }