Пример #1
0
        public async Task <IActionResult> ValidateActiveCode([FromBody] ValidateActiceCodeDto dto)
        {
            var result = await _loginService.ValidateResetPasswordActiveCodeAsync(dto);

            if (!result.Succeeded)
            {
                return(BadRequest(ApiErrorCodes.ResetPasswordActiveCodeIsIncorrect, "Reset password active code is incorrect."));
            }

            return(Success(((ServiceResult <string>)result).Result));
        }
Пример #2
0
        public async Task <ServiceResult> ValidateResetPasswordActiveCodeAsync(ValidateActiceCodeDto dto)
        {
            var user = await GetLoginByEmailAsync(dto.Email);

            if (user == null)
            {
                throw new BusinessException("Địa chỉ email không tồn tại trong hệ thống.");
            }

            await CheckTokenExistAsync(dto.Token);

            if (!_dataProtectorUserTokenService.ValidateResetPasswordToken(user.Id, dto.Token))
            {
                return(ServiceResult.Failed());
            }

            return(ServiceResult <string> .Success(dto.Token));
        }