fix: merge customer and manager login (#38)
Release package / release (push) Successful in 13m32s
Release package / release (push) Successful in 13m32s
Co-authored-by: Copilot <copilot@github.com> Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com> Reviewed-on: #38
This commit was merged in pull request #38.
This commit is contained in:
@@ -11,7 +11,7 @@ import java.util.*;
|
|||||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||||
|
|
||||||
@Path("/api/" + Role.Customer)
|
@Path("/api/" + Role.Customer)
|
||||||
public class CustomerController extends BaseController {
|
public class CustomerController {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@RestClient
|
@RestClient
|
||||||
@@ -23,12 +23,6 @@ public class CustomerController extends BaseController {
|
|||||||
return accountService.signup(input);
|
return accountService.signup(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path(Url.Login)
|
|
||||||
public Uni<Response> proxyLogin(Login input) {
|
|
||||||
return accountService.login(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
@POST
|
@POST
|
||||||
@Path(Url.QuickSignup)
|
@Path(Url.QuickSignup)
|
||||||
public Uni<Response> proxyQuickSignup(QuickSignup input) {
|
public Uni<Response> proxyQuickSignup(QuickSignup input) {
|
||||||
|
|||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package com.drinkool.controller;
|
||||||
|
|
||||||
|
import com.drinkool.Url;
|
||||||
|
import com.drinkool.dtos.Login;
|
||||||
|
import com.drinkool.services.CustomerService;
|
||||||
|
import com.drinkool.services.ManagerService;
|
||||||
|
import io.smallrye.mutiny.Uni;
|
||||||
|
import jakarta.inject.Inject;
|
||||||
|
import jakarta.ws.rs.POST;
|
||||||
|
import jakarta.ws.rs.Path;
|
||||||
|
import jakarta.ws.rs.core.Response;
|
||||||
|
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||||
|
|
||||||
|
@Path("/api")
|
||||||
|
public class MainController extends BaseController {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@RestClient
|
||||||
|
ManagerService managerService;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@RestClient
|
||||||
|
CustomerService customerService;
|
||||||
|
|
||||||
|
@POST
|
||||||
|
@Path(Url.Login)
|
||||||
|
public Uni<Response> proxyLogin(Login input) {
|
||||||
|
return managerService
|
||||||
|
.login(input)
|
||||||
|
.onFailure()
|
||||||
|
.recoverWithUni(() -> {
|
||||||
|
return customerService.login(input);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -11,7 +11,7 @@ import java.util.*;
|
|||||||
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
import org.eclipse.microprofile.rest.client.inject.RestClient;
|
||||||
|
|
||||||
@Path("/api/" + Role.Manager)
|
@Path("/api/" + Role.Manager)
|
||||||
public class ManagerController extends BaseController {
|
public class ManagerController {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@RestClient
|
@RestClient
|
||||||
@@ -23,12 +23,6 @@ public class ManagerController extends BaseController {
|
|||||||
return managerService.signup(input);
|
return managerService.signup(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
@POST
|
|
||||||
@Path(Url.Login)
|
|
||||||
public Uni<Response> proxyLogin(Login input) {
|
|
||||||
return managerService.login(input);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
public Uni<Response> me(@HeaderParam(InternalValue.userId) UUID id) {
|
public Uni<Response> me(@HeaderParam(InternalValue.userId) UUID id) {
|
||||||
return managerService.me(id);
|
return managerService.me(id);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class BaseControllerTest {
|
|||||||
public void testLogoutShouldClearCookie() {
|
public void testLogoutShouldClearCookie() {
|
||||||
given()
|
given()
|
||||||
.when()
|
.when()
|
||||||
.post("/api/" + Role.Customer + Url.Logout)
|
.post("/api" + Url.Logout)
|
||||||
.then()
|
.then()
|
||||||
.statusCode(204)
|
.statusCode(204)
|
||||||
.header("Set-Cookie", containsString(InternalValue.cookieName))
|
.header("Set-Cookie", containsString(InternalValue.cookieName))
|
||||||
|
|||||||
Reference in New Issue
Block a user