temp authentication user

This commit is contained in:
dirgantarasiahaan
2023-05-25 11:55:47 +07:00
parent 77dfe44ee6
commit d50b2a8eef
16 changed files with 368 additions and 78 deletions

View File

@ -0,0 +1,35 @@
package com.iconplus.smartproc.controller;
import com.iconplus.smartproc.model.request.LoginRequest;
import com.iconplus.smartproc.model.request.RefreshTokenRequest;
import com.iconplus.smartproc.model.response.LoginResponse;
import com.iconplus.smartproc.model.response.RefreshTokenResponse;
import com.iconplus.smartproc.service.authentication.LoginService;
import com.iconplus.smartproc.service.authentication.TokenManagementService;
import org.springframework.web.bind.annotation.*;
@CrossOrigin(origins = "http://localhost:8080", allowCredentials = "true")
@RestController
@RequestMapping("/api/authentication")
public class AuthenticationController {
private LoginService loginService;
private TokenManagementService tokenManagementService;
public AuthenticationController(LoginService loginService,
TokenManagementService tokenManagementService) {
this.loginService = loginService;
this.tokenManagementService = tokenManagementService;
}
@PostMapping("/login")
public LoginResponse getLoginResponse(@RequestBody LoginRequest loginRequest) {
return loginService.execute(loginRequest);
}
@PostMapping("/refresh-token")
public RefreshTokenResponse getRefreshToken(@RequestBody RefreshTokenRequest refreshTokenRequest) {
return tokenManagementService.execute(refreshTokenRequest);
}
}