Files
backend/gateway-service/src/main/java/com/drinkool/CustomerGatewayResource.java
T
TakahashiNguyen a2b9de91f5
Release package / release (push) Failing after 2m57s
feat: init customer authentication (#2)
Co-authored-by: TakahashiNg <83152264+TakahashiNguyen@users.noreply.github.com>
Co-authored-by: gitea-actions <actions-user@noreply.git.demonkernel.io.vn>
Reviewed-on: #2
2026-03-23 13:21:00 +00:00

45 lines
1.0 KiB
Java

package com.drinkool;
import com.drinkool.dtos.*;
import com.drinkool.services.AccountService;
import io.quarkus.redis.datasource.RedisDataSource;
import io.smallrye.mutiny.Uni;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.Response;
import org.eclipse.microprofile.rest.client.inject.RestClient;
@Path("/api/v1/customers")
public class CustomerGatewayResource {
@Inject
@RestClient
AccountService accountService;
@Inject
RedisDataSource redisDataSource;
@POST
@Path("/signup")
public Uni<Response> proxySignup(Signup input) {
String otpVerifiedKey = "otp:verified:" + input.phone;
var valueCmd = redisDataSource.value(String.class);
if (valueCmd.get(otpVerifiedKey) == null) {
return Uni.createFrom().item(
Response.status(Response.Status.FORBIDDEN)
.entity("Phone not verified")
.build()
);
}
return accountService.signup(input);
}
@POST
@Path("/login")
public Uni<Response> proxyLogin(Login input) {
return accountService.login(input);
}
}