public async Task ActivateAsync(string email, string token)
        {
            await _seruredOperationService.ConsumeAsync(OneTimeSecuredOperations.ActivateAccount,
                                                        email, token);

            var user = await _userRepository.GetByEmailAsync(email, Providers.Collectively);

            if (user.HasNoValue)
            {
                throw new ServiceException(OperationCodes.UserNotFound,
                                           $"User with email: '{email}' has not been found.");
            }
            user.Value.Activate();
            await _userRepository.UpdateAsync(user.Value);
        }
예제 #2
0
        public async Task SetNewAsync(string email, string token, string password)
        {
            var user = await _userRepository.GetByEmailAsync(email);

            if (user.HasNoValue())
            {
                throw new ServiceException(Codes.UserNotFound,
                                           $"User with email: '{email}' has not been found.");
            }

            await _oneTimeSecuredOperationService.ConsumeAsync(OneTimeSecuredOperations.ResetPassword,
                                                               user.Id, token);

            user.SetPassword(password, _encrypter);
            _userRepository.EditUser(user);
        }
        public async Task ActivateAsync(string email, string token)
        {
            var user = await _userRepository.GetByEmailAsync(email);

            if (user.HasNoValue())
            {
                throw new ServiceException(Codes.UserNotFound,
                                           $"User with email: '{email}' has not been found.");
            }

            await _securedOperationService.ConsumeAsync(
                OneTimeSecuredOperations.ActivateAccount, user.Id, token);

            user.Activate();
            _userRepository.EditUser(user);
        }
예제 #4
0
        public async Task SetNewAsync(string email, string token, string password)
        {
            var user = await _userRepository.GetByEmailAsync(email, Providers.Collectively);

            if (user.HasNoValue)
            {
                throw new ServiceException(OperationCodes.UserNotFound,
                                           $"User with email: '{email}' has not been found.");
            }

            await _oneTimeSecuredOperationService.ConsumeAsync(OneTimeSecuredOperations.ResetPassword,
                                                               email, token);

            user.Value.SetPassword(password, _encrypter);
            await _userRepository.UpdateAsync(user.Value);
        }