public void SavePasswordChangeRequest(PasswordChangeRequest request)
        {
            Require.NotNull(request, nameof(request));

            var session = _sessionProvider.GetCurrentSession();

            session.Save(request);
        }
Example #2
0
        public void DeletePasswordChangeRequest(PasswordChangeRequest request)
        {
            Require.NotNull(request, nameof(request));

            _passwordChangeRequestRepository.DeletePasswordChangeRequest(request);
        }
        public void InitiatePasswordChangingProcedure(int userId)
        {
            Require.Positive(userId, nameof(userId));

            var userToInitiateProcedure = GetUser(userId);

            var request = _passwordManager.GetPasswordChangeRequest(userId);

            if (_passwordManager.GetPasswordChangeRequest(userId) == null)
            {
                request = new PasswordChangeRequest(userId, TokenGenerator.GenerateToken());
            }

            var passwordChangeRequest = request;

            var link = $"{_applicationLocationSettings.FrontendAdress}/password/recovery/{passwordChangeRequest.Token}";

            _passwordManager.SavePasswordChangeRequest(request);

            _mailer.SendPasswordResetMail(link, userToInitiateProcedure.Email);
        }