Skip to content

Commit

Permalink
Move /redirect for video
Browse files Browse the repository at this point in the history
  • Loading branch information
delbaoliveira committed Apr 24, 2024
1 parent b129ee2 commit 56ad0e5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 0 additions & 4 deletions app/auth/01-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
import { createSession, deleteSession } from '@/app/auth/02-stateless-session';
import bcrypt from 'bcrypt';
import { eq } from 'drizzle-orm';
import { redirect } from 'next/navigation';

export async function signup(
state: FormState,
Expand Down Expand Up @@ -68,7 +67,6 @@ export async function signup(
// 4. Create a session for the user
const userId = user.id.toString();
await createSession(userId);
redirect('/dashboard');
}

export async function login(
Expand Down Expand Up @@ -112,10 +110,8 @@ export async function login(
// 4. If login successful, create a session for the user and redirect
const userId = user.id.toString();
await createSession(userId);
redirect('/dashboard');
}

export async function logout() {
deleteSession();
redirect('/login');
}
3 changes: 3 additions & 0 deletions app/auth/02-stateless-session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export async function createSession(userId: string) {
sameSite: 'lax',
path: '/',
});

redirect('/dashboard');
}

export async function verifySession() {
Expand Down Expand Up @@ -71,4 +73,5 @@ export async function updateSession() {

export function deleteSession() {
cookies().delete('session');
redirect('/login');
}

0 comments on commit 56ad0e5

Please sign in to comment.