Пример #1
0
        public virtual async Task <AuthResult> CreateAsync(TUser user, string password)
        {
            ThrowIfDisposed();
            IUserPasswordStore <TUser> passwordStore = GetPasswordStore();

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }
            if (password == null)
            {
                throw new ArgumentNullException(nameof(password));
            }

            AuthResult result = await UpdatePasswordHash(passwordStore, user, password);

            if (!result.Succeeded)
            {
                return(result);
            }

            return(await CreateAsync(user));
        }
Пример #2
0
        public virtual async Task <AuthResult> ValidateAsync(UserManager <TUser> manager, TUser user)
        {
            if (manager == null)
            {
                throw new ArgumentNullException(nameof(manager));
            }

            if (user == null)
            {
                throw new ArgumentNullException(nameof(user));
            }

            List <AuthError> errors = new List <AuthError>();

            await ValidateUserName(manager, user, errors);

            if (manager.Options.Users.RequireUniqueEmail)
            {
                await ValidateEmail(manager, user, errors);
            }

            return(errors.Count > 0 ? AuthResult.Failed(errors.ToArray()) : AuthResult.Success);
        }