-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/landing-page
- Loading branch information
Showing
61 changed files
with
3,258 additions
and
832 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { NextResponse } from "next/server"; | ||
import { Context, Next } from "hono"; | ||
|
||
export const checkAdmin = async (c: Context, next: Next) => { | ||
try { | ||
const session = c.get("session"); | ||
if (session && session.user && session.user.role === "admin") { | ||
return await next(); | ||
} | ||
return NextResponse.json( | ||
{ message: "You are not authorized" }, | ||
{ status: 401 }, | ||
); | ||
} catch (error) { | ||
console.log("Check admin middleware error", error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { auth } from "@plura/auth"; | ||
import { Context, Next } from "hono"; | ||
import { NextResponse } from "next/server"; | ||
|
||
export const checkLogin = async (c: Context, next: Next) => { | ||
try { | ||
const session = await auth.api.getSession({ headers: c.req.raw.headers }); | ||
if (session && session.user) { | ||
c.set("session", session); | ||
return await next(); | ||
} | ||
return NextResponse.json( | ||
{ message: "You are not authorized" }, | ||
{ status: 401 }, | ||
); | ||
} catch (error) { | ||
console.log("Check login middleware error", error); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.