mirror of
https://github.com/simstudioai/sim.git
synced 2026-09-24 15:45:35 +08:00
fix: route to /w after signup, remove deprecated getSessionCookie function
This commit is contained in:
Generated
-6
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "sim",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {}
|
||||
}
|
||||
@@ -65,7 +65,7 @@ export default function SignupPage() {
|
||||
|
||||
async function signUpWithGithub() {
|
||||
try {
|
||||
await client.signIn.social({ provider: 'github' })
|
||||
await client.signIn.social({ provider: 'github', callbackURL: '/w' })
|
||||
} catch (err: any) {
|
||||
let errorMessage = 'Failed to sign up with GitHub'
|
||||
|
||||
@@ -85,7 +85,7 @@ export default function SignupPage() {
|
||||
|
||||
async function signUpWithGoogle() {
|
||||
try {
|
||||
await client.signIn.social({ provider: 'google' })
|
||||
await client.signIn.social({ provider: 'google', callbackURL: '/w' })
|
||||
} catch (err: any) {
|
||||
let errorMessage = 'Failed to sign up with Google'
|
||||
|
||||
|
||||
+11
-3
@@ -1,5 +1,4 @@
|
||||
import { NextRequest, NextResponse } from 'next/server'
|
||||
import { getSessionCookie } from 'better-auth'
|
||||
|
||||
export async function middleware(request: NextRequest) {
|
||||
// Check if the path is exactly /w
|
||||
@@ -12,8 +11,17 @@ export async function middleware(request: NextRequest) {
|
||||
return NextResponse.next()
|
||||
}
|
||||
|
||||
// Existing auth check for protected routes
|
||||
const sessionCookie = getSessionCookie(request)
|
||||
const cookieHeader = request.headers.get("cookie");
|
||||
const cookies = cookieHeader?.split("; ").reduce((acc, cookie) => {
|
||||
const [key, value] = cookie.split("=");
|
||||
acc.set(key, value);
|
||||
return acc;
|
||||
}, new Map());
|
||||
|
||||
const sessionCookie =
|
||||
cookies?.get("better-auth.session_token") ||
|
||||
cookies?.get("__Secure-better-auth.session_token");
|
||||
|
||||
if (!sessionCookie) {
|
||||
return NextResponse.redirect(new URL('/login', request.url))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user