public async Task <IActionResult> Authenticate(UserCaptchaDto userCaptchaDto) { if (userCaptchaDto != null && CaptchaResponseValid(userCaptchaDto.CaptchaResponse)) { var userDto = userCaptchaDto.User; try { var user = await _userService.AuthenticateAsync(userDto.Email, userDto.Password); if (user == null) { return(BadRequest(new BadRequestError("Something about this Email Password combination was incorrect"))); } return(Ok(user)); } catch (SignInUserServiceException exception) { if (exception.SignInResult.IsNotAllowed) { return(BadRequest(new BadRequestError("You need to confirm your E-Mail address before logging in!"))); } return(BadRequest(new BadRequestError("Login failed. Please verify your E-Mail and Password and try again!"))); } } return(BadRequest(new BadRequestError("Captcha was invalid"))); }
public async Task <IActionResult> ResendConfirmationEmail(UserCaptchaDto userCaptchaDto) { if (userCaptchaDto != null && CaptchaResponseValid(userCaptchaDto.CaptchaResponse)) { if (userCaptchaDto.User == null || string.IsNullOrWhiteSpace(userCaptchaDto.User.Email)) { return(BadRequest(new BadRequestError("Email has to be set to resend a confirmation email"))); } try { await _userService.ResendConfirmationMailAsync(userCaptchaDto.User.Email); } catch (UserServiceException exception) { _logger.LogWarning(exception.Message); } return(Ok()); } return(BadRequest(new BadRequestError("Captcha was invalid"))); }
public async Task <IActionResult> Register(UserCaptchaDto userCaptchaDto) { if (userCaptchaDto != null && !CaptchaResponseValid(userCaptchaDto.CaptchaResponse)) { return(BadRequest(new BadRequestError("Captcha was invalid"))); } try { var createdUser = await _userService.CreateAsync(userCaptchaDto?.User); if (createdUser != null) { return(Ok(createdUser)); } } catch (IdentityUserServiceException exception) { return(BadRequest(new BadRequestError(exception.ToString()))); } return(BadRequest(new BadRequestError("Something went wrong processing this registration"))); }