public async Task <IdentityResult> SetPasswordAsync(User user, string masterPassword, string key, string orgIdentifier = null) { if (user == null) { throw new ArgumentNullException(nameof(user)); } if (!string.IsNullOrWhiteSpace(user.MasterPassword)) { Logger.LogWarning("Change password failed for user {userId} - already has password.", user.Id); return(IdentityResult.Failed(_identityErrorDescriber.UserAlreadyHasPassword())); } var result = await UpdatePasswordHash(user, masterPassword, true, false); if (!result.Succeeded) { return(result); } user.RevisionDate = user.AccountRevisionDate = DateTime.UtcNow; user.Key = key; await _userRepository.ReplaceAsync(user); await _eventService.LogUserEventAsync(user.Id, EventType.User_ChangedPassword); if (!string.IsNullOrWhiteSpace(orgIdentifier)) { await _organizationService.AcceptUserAsync(orgIdentifier, user, this); } return(IdentityResult.Success); }
public async Task Accept(string orgId, string id, [FromBody] OrganizationUserAcceptRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); if (user == null) { throw new UnauthorizedAccessException(); } var result = await _organizationService.AcceptUserAsync(new Guid(id), user, model.Token); }
public async Task Accept(string orgId, string id, [FromBody] OrganizationUserAcceptRequestModel model) { var user = await _userService.GetUserByPrincipalAsync(User); var result = await _organizationService.AcceptUserAsync(new Guid(id), user, model.Token); }