Beispiel #1
0
        public async Task <IActionResult> ForgotPassword(ForgotPasswordRequestDTO model)
        {
            try
            {
                await _accountService.ForgotPassword(model.Username, model.Email);

                return(Ok());
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
        public async Task ForgotPassword(ForgotPasswordRequestDTO model, string origin)
        {
            var user = _userData.GetByEmail(model.Email);

            if (user == null)
            {
                return;
            }

            // create reset token that expires after 1 day
            user.ResetToken          = JwtToken.randomTokenString();
            user.ResetTokenExpiresAt = DateTime.UtcNow.AddHours(24);

            _userData.Update(user);

            await SendPasswordResetEmail(user, origin);
        }
        public async Task ForgotPasswordAsync(ForgotPasswordRequestDTO model, string origin)
        {
            var account = await this._repository.GetByAsync((e => e.Email == model.Email));

            if (account == null)
            {
                return;
            }

            if (!account.Active)
            {
                throw new ApplicationException("Conta desativada!");
            }

            account.ResetToken        = this.RandomTokenString();
            account.ResetTokenExpires = DateTime.UtcNow.AddDays(24);

            await this._repository.UpdateAsync(account.ID, account);

            await this._repository.SaveChangesAsync();
        }
        public async Task <ActionResult> ForgotPassword(ForgotPasswordRequestDTO model)
        {
            await _userService.ForgotPassword(model, Request.Headers["origin"]);

            return(Ok(new { message = $"Please check your email for password reset instructions {_smtpSettings.EmailFrom}" }));
        }