Created
December 25, 2013 12:40
-
-
Save blachniet/8122919 to your computer and use it in GitHub Desktop.
Comment question at http://blachniet.com/2013/11/10/email-addresses-as-user-names-in-asp-net-identity/#comment-1175501695
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public Task CreateAsync(ApplicationUser user) | |
| { | |
| if (user == null) | |
| { | |
| throw new ArgumentNullException("user cannot be null."); | |
| } | |
| if (string.IsNullOrEmpty(user.UserName)) | |
| { | |
| throw new ArgumentNullException("username cannot be null or empty."); | |
| } | |
| if (string.IsNullOrEmpty(user.Email)) | |
| { | |
| throw new ArgumentNullException("email cannot be null or empty."); | |
| } | |
| //compile errors like username or email already taken... | |
| var errors = GetErrors(user); | |
| if (errors.Any()) | |
| { | |
| return Task.FromResult<identityresult>(IdentityResult.Failed(errors.ToArray())); | |
| } | |
| userBusiness.AddUser(user.ToUser()); | |
| return Task.FromResult<identityresult>(null); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment