fix: fixed redirecting
Build and Deploy / test-backend (push) Successful in 1m15s
Build and Deploy / lint-frontend (push) Successful in 1m13s
Build and Deploy / build-backend (push) Successful in 50s
Build and Deploy / build-frontend (push) Successful in 40s
Build and Deploy / deploy (push) Successful in 6s
Build and Deploy / test-backend (push) Successful in 1m15s
Build and Deploy / lint-frontend (push) Successful in 1m13s
Build and Deploy / build-backend (push) Successful in 50s
Build and Deploy / build-frontend (push) Successful in 40s
Build and Deploy / deploy (push) Successful in 6s
This commit is contained in:
@@ -32,7 +32,7 @@ func (h *OAuthHandler) Authorize(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
c.Redirect(http.StatusFound, h.frontendURL+"/oauth?session="+token)
|
||||
c.Redirect(http.StatusFound, h.frontendURL+"/login?session="+token)
|
||||
}
|
||||
|
||||
func (h *OAuthHandler) GetSession(c *gin.Context) {
|
||||
|
||||
@@ -9,10 +9,10 @@ export async function proxy(request: NextRequest) {
|
||||
const isPublicPath = PUBLIC_PATHS.includes(pathname);
|
||||
const session = request.nextUrl.searchParams.get("session");
|
||||
|
||||
if (session && pathname === "/login") {
|
||||
if (hasRefreshToken && session && pathname === "/login") {
|
||||
const accessToken = request.cookies.get("access_token")?.value;
|
||||
try {
|
||||
await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/attach`, {
|
||||
const res = await fetch(`${process.env.KOTOSOFT_ID_API_URL}/oauth/session/attach`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -20,6 +20,7 @@ export async function proxy(request: NextRequest) {
|
||||
},
|
||||
body: JSON.stringify({ session }),
|
||||
});
|
||||
if (!res.ok) throw new Error("attach failed");
|
||||
} catch (error) {
|
||||
console.error("Failed to attach session:", error);
|
||||
return NextResponse.redirect(new URL("/callback/error", request.url));
|
||||
@@ -27,11 +28,7 @@ export async function proxy(request: NextRequest) {
|
||||
return NextResponse.redirect(new URL(`/consent?session=${session}`, request.url));
|
||||
}
|
||||
|
||||
if (session && pathname === "/consent") {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
if (hasRefreshToken && !session && (isPublicPath || pathname === "/")) {
|
||||
if (hasRefreshToken && (isPublicPath || pathname === "/")) {
|
||||
return NextResponse.redirect(new URL("/me", request.url));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user