generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Arquisoft/develop
v0.5.0
- Loading branch information
Showing
96 changed files
with
1,897 additions
and
16,811 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.addLombokGeneratedAnnotation = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 17 additions & 13 deletions
30
api/src/main/java/lab/en2b/quizapi/auth/AuthController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,37 @@ | ||
package lab.en2b.quizapi.auth; | ||
|
||
import jakarta.validation.Valid; | ||
import lab.en2b.quizapi.auth.dtos.LoginDto; | ||
import lab.en2b.quizapi.auth.dtos.RefreshTokenDto; | ||
import lab.en2b.quizapi.auth.dtos.RegisterDto; | ||
import lab.en2b.quizapi.auth.dtos.*; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
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 org.springframework.security.core.Authentication; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
@RestController | ||
@RequestMapping("/auth") | ||
@RequiredArgsConstructor | ||
public class AuthController { | ||
private final AuthService authService; | ||
|
||
@PostMapping("/register") | ||
public ResponseEntity<?> registerUser(@Valid @RequestBody RegisterDto registerRequest){ | ||
return authService.register(registerRequest); | ||
public ResponseEntity<String> registerUser(@Valid @RequestBody RegisterDto registerRequest){ | ||
authService.register(registerRequest); | ||
return ResponseEntity.ok("User registered successfully!"); | ||
} | ||
|
||
@PostMapping("/login") | ||
public ResponseEntity<?> loginUser(@Valid @RequestBody LoginDto loginRequest){ | ||
return authService.login(loginRequest); | ||
public ResponseEntity<JwtResponseDto> loginUser(@Valid @RequestBody LoginDto loginRequest){ | ||
return ResponseEntity.ok(authService.login(loginRequest)); | ||
} | ||
|
||
@GetMapping("/logout") | ||
public ResponseEntity<Void> logoutUser(Authentication authentication){ | ||
authService.logOut(authentication); | ||
return ResponseEntity.noContent().build(); | ||
} | ||
|
||
@PostMapping("/refresh-token") | ||
public ResponseEntity<?> refreshToken(@Valid @RequestBody RefreshTokenDto refreshTokenRequest){ | ||
return authService.refreshToken(refreshTokenRequest); | ||
public ResponseEntity<RefreshTokenResponseDto> refreshToken(@Valid @RequestBody RefreshTokenDto refreshTokenRequest){ | ||
return ResponseEntity.ok(authService.refreshToken(refreshTokenRequest)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.