add api context and logout

This commit is contained in:
dirgantarasiahaan
2023-05-25 15:39:36 +07:00
parent f0dfef725a
commit c4700af832
8 changed files with 377 additions and 1 deletions

View File

@ -1,10 +1,13 @@
package com.iconplus.smartproc.controller;
import com.iconplus.smartproc.helper.model.EmptyRequest;
import com.iconplus.smartproc.helper.model.EmptyResponse;
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.LogoutService;
import com.iconplus.smartproc.service.authentication.TokenManagementService;
import org.springframework.web.bind.annotation.*;
@ -15,11 +18,14 @@ public class AuthenticationController {
private LoginService loginService;
private TokenManagementService tokenManagementService;
private LogoutService logoutService;
public AuthenticationController(LoginService loginService,
TokenManagementService tokenManagementService) {
TokenManagementService tokenManagementService,
LogoutService logoutService) {
this.loginService = loginService;
this.tokenManagementService = tokenManagementService;
this.logoutService = logoutService;
}
@PostMapping("/login")
@ -32,4 +38,10 @@ public class AuthenticationController {
return tokenManagementService.execute(refreshTokenRequest);
}
@PostMapping("/logout")
public EmptyResponse logoutUser(EmptyRequest request) {
return logoutService.execute(request);
}
}