Skip to content

Commit

Permalink
role based access
Browse files Browse the repository at this point in the history
  • Loading branch information
siinghd committed Mar 4, 2024
1 parent 13cf592 commit a95f23a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ BOT_TOKEN = "123"
GUILD_ID = "123"
LOCAL_CMS_PROVIDER = true
CACHE_EXPIRE_S = 10

ADMINS = "Random,[email protected]"
12 changes: 12 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/lib/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ export const authOptions = {
if (session?.user) {
session.user.id = token.uid;
session.user.jwtToken = token.jwtToken;
session.user.role = process.env.ADMINS?.split(',').includes(
session.user.email,
)
? 'admin'
: 'user';
}

return session;
Expand Down

0 comments on commit a95f23a

Please sign in to comment.