brevo smtp server (300 mails/day free)
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
LocationBasedServices/sumoc-backend/pipeline/head This commit looks good
Test written for changing Password based on otp some other stuff
This commit is contained in:
@@ -14,12 +14,15 @@ import io.swagger.v3.oas.annotations.responses.ApiResponses;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.mail.MailException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/auth/user")
|
||||
public class UserAuthenticationController {
|
||||
@@ -77,7 +80,7 @@ public class UserAuthenticationController {
|
||||
}
|
||||
|
||||
@PostMapping("/request-password-forgot")
|
||||
public ResponseEntity<String> handleForgotPasswordRequest(@RequestBody String email){
|
||||
public ResponseEntity<String> handleForgotPasswordRequest(@RequestBody String email, Principal principal){
|
||||
System.out.println("####################### Handle Password Reset Request #######################");
|
||||
System.out.println(email);
|
||||
|
||||
@@ -86,6 +89,9 @@ public class UserAuthenticationController {
|
||||
return ResponseEntity.ok("OTP Token erstellt");
|
||||
} catch (UsernameNotFoundException e) {
|
||||
return ResponseEntity.badRequest().body(e.getMessage());
|
||||
} catch(MailException e){
|
||||
System.out.println(" ## MAIL EXCEPTION \n" +e.getMessage());
|
||||
return ResponseEntity.internalServerError().body("Fehler beim versenden der Email, versuche es später erneut");
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.internalServerError().body("Fehler beim erstellen des OTP Tokens");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user