public async Task <IActionResult> RevokeRefreshToken(string refreshToken) { if (string.IsNullOrWhiteSpace(refreshToken)) { return(BadRequest(OAuthBadRequest)); } try { ContextPrincipal principal = new ContextPrincipal(HttpContext.User); RefreshToken token = await unitOfWork.TokenRepository.FindOneAsync( t => t.UserId.Equals(principal.UserId) && t.RefreshTokenValue.Equals(refreshToken), o => o.OrderBy(u => u.Id), null ); if (null != token) { unitOfWork.TokenRepository.Delete(token); await unitOfWork.Save(); return(Ok()); } else { return(NotFound()); } } catch (Exception) { return(BadRequest(OAuthBadRequest)); } }
public async Task <OperationDetails> RemoveUser(string userId) { ApplicationUser user = _db.UserManager.Users.FirstOrDefault(u => u.Id == userId); if (user == null) { return(new OperationDetails(succedeed: false, message: "User not found", prop: "")); } var result = _db.UserManager.Delete(user); if (result.Succeeded) { _db.Save(); return(new OperationDetails(succedeed: true, message: "The user has been successfully deleted", prop: "")); } else { return(new OperationDetails(succedeed: false, message: result.Errors.FirstOrDefault(), prop: "")); } }