File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
src/main/java/dev/ralo/example/authentication Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change 11package dev .ralo .example .authentication ;
22
3+ import dev .ralo .example .registration .ConfirmationTokenService ;
34import dev .ralo .example .registration .RegistrationRequest ;
45import lombok .RequiredArgsConstructor ;
56import org .springframework .http .ResponseEntity ;
6- import org .springframework .web .bind .annotation .PostMapping ;
7- import org .springframework .web .bind .annotation .RequestBody ;
8- import org .springframework .web .bind .annotation .RequestMapping ;
9- import org .springframework .web .bind .annotation .RestController ;
7+ import org .springframework .web .bind .annotation .*;
108
119@ RestController
1210@ RequestMapping ("/api/auth" )
1311@ RequiredArgsConstructor
1412public class AuthenticationController {
1513
1614 private final AuthenticationService authenticationService ;
15+ private final ConfirmationTokenService confirmationTokenService ;
1716
1817 @ PostMapping ("/signin" )
1918 public ResponseEntity <Object > authenticate (@ RequestBody AuthenticationRequest authenticationRequest ) {
@@ -33,4 +32,14 @@ public ResponseEntity<Object> register(@RequestBody RegistrationRequest registra
3332 return ResponseEntity .badRequest ().body (e .getMessage ());
3433 }
3534 }
35+
36+ @ GetMapping ("/confirm" )
37+ public ResponseEntity <Object > confirm (@ RequestParam ("token" ) String token ) {
38+ try {
39+ confirmationTokenService .confirmToken (token );
40+ return ResponseEntity .ok ("Thank you! Your account is now verified" );
41+ } catch (Exception e ) {
42+ return ResponseEntity .badRequest ().body (e .getMessage ());
43+ }
44+ }
3645}
You can’t perform that action at this time.
0 commit comments