implement better-auth auth with postgres and route protection
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { jsonError } from '@/lib/server/http';
|
||||
import { requireAuthenticatedSession } from '@/lib/server/auth-session';
|
||||
import { getTaskById } from '@/lib/server/tasks';
|
||||
|
||||
type Context = {
|
||||
@@ -6,8 +7,13 @@ type Context = {
|
||||
};
|
||||
|
||||
export async function GET(_request: Request, context: Context) {
|
||||
const { session, response } = await requireAuthenticatedSession();
|
||||
if (response) {
|
||||
return response;
|
||||
}
|
||||
|
||||
const { taskId } = await context.params;
|
||||
const task = await getTaskById(taskId);
|
||||
const task = await getTaskById(taskId, session.user.id);
|
||||
|
||||
if (!task) {
|
||||
return jsonError('Task not found', 404);
|
||||
|
||||
Reference in New Issue
Block a user