public async Task <ActionResult <Response <UserModel> > > SendForgotPasswordEmail(
            [FromBody] ForgotPasswordUserRequest request)
        {
            var response = await _identityService.SendForgotPasswordEmail(request);

            return(Ok(response));
        }
Exemplo n.º 2
0
        public async Task <ActionResult <UserModelResult> > SendForgotPasswordEmail([FromBody] ForgotPasswordUserRequest request)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var result = await _usersService.SendForgotPasswordEmail(request);

            if (!result.Success)
            {
                return(BadRequest(result));
            }

            return(result);
        }
Exemplo n.º 3
0
        public async Task <UserModelResult> SendForgotPasswordEmail(ForgotPasswordUserRequest request)
        {
            var identity = await _userManager.Users.FirstOrDefaultAsync(u => u.UserName == request.Username);

            if (identity == null)
            {
                return(new UserModelResult("Username does not exist!"));
            }
            var user = await _db.Users.FirstOrDefaultAsync(u => u.AspNetUserId == identity.Id);

            var token = await _userManager.GenerateEmailConfirmationTokenAsync(identity);

            var template = await GetUserEmailAsync(identity, user, _templateData.ForgotPasswordEmailFileName, "reset-password", token);

            await _emailClient.Send(identity.Email, "Forgot password notification", template);

            return(new UserModelResult {
                Success = true
            });
        }
Exemplo n.º 4
0
        public async Task <Response <UserModel> > SendForgotPasswordEmail(ForgotPasswordUserRequest request)
        {
            var identity = await _userManager.Users.FirstOrDefaultAsync(u => u.Email == request.Email);

            if (identity == null)
            {
                _logger.LogWarning($"Username {request.Email} does not exist.");
                return(Response <UserModel> .ForSuccess());
            }

            var user = await _usersRepository.GetByIdentity(identity.Id);

            var token = await _userManager.GenerateEmailConfirmationTokenAsync(identity);

            var template = await GetUserEmailAsync(identity, user, _templateData.ForgotPasswordEmailFileName, "reset-password", token);

            await _emailClient.Send(identity.Email, "Forgot password notification", template);

            _logger.LogInformation($"Reset password email sent for {request.Email}.");

            return(Response <UserModel> .ForSuccess());
        }
Exemplo n.º 5
0
        public Task <Response <UserModel> > SendForgotPasswordEmail(ForgotPasswordUserRequest request)
        {
            Response <UserModel> response = Response.ForError("");

            return(Task.FromResult(response));
        }