public virtual async Task<IdentityResult> RemoveLoginAsync(string userId, UserLinkedLogin userLinkedLogin) { User user = await this.FindByIdAsync(userId); if (user == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.UserIdNotFound, userId)); } await this.userRepository.RemoveLoginAsync(user, userLinkedLogin); user.SecurityStamp = this.CreateSecurityStamp(); IdentityResult identityResult = await this.UpdateAsync(user); return identityResult; }
public virtual async Task<User> FindByLoginAsync(UserLinkedLogin userLinkedLogin) { var user = await this.userRepository.FindByLoginAsync(userLinkedLogin); return user; }
public virtual async Task<IdentityResult> CreateLoginAsync(string userId, UserLinkedLogin userLinkedLogin) { User userFoundById = await this.FindByIdAsync(userId); if (userFoundById == null) { throw new InvalidOperationException(string.Format(CultureInfo.CurrentCulture, Resource.UserIdNotFound, userId)); } IdentityResult identityResult; User userFoundByLogin = await this.FindByLoginAsync(userLinkedLogin); if (userFoundByLogin != null) { identityResult = new IdentityResult(false, new[] { Resource.ExternalLoginExists }); } else { await this.userRepository.AddLoginAsync(userFoundById, userLinkedLogin); identityResult = await this.UpdateAsync(userFoundById); } return identityResult; }