Beispiel #1
0
        public async Task <ChangePasswordResult> ChangePassword(
            Guid id,
            string currentPassword,
            string password1,
            string password2)
        {
            var identity = await _identityRepository.Get(id);

            if (password1 != password2)
            {
                return(ChangePasswordResult.PasswordsDontMatch);
            }
            if (!_cryptoManager.CheckPassword(currentPassword, identity.Password))
            {
                return(ChangePasswordResult.InvalidCurrentPassword);
            }

            identity.Password = _cryptoManager.HashPassword(password1);
            await _identityRepository.Update(identity);

            return(ChangePasswordResult.Ok);
        }