Adding some debug stuff on admin

This commit is contained in:
Keith Stevens
2023-01-09 15:25:02 +09:00
parent 0e9fd9a140
commit 2ca2abf4c1
2 changed files with 5 additions and 0 deletions
+1
View File
@@ -22,6 +22,7 @@ const AdminIndex = () => {
if (status === "loading") {
return;
}
console.log("checking role: " + session?.user?.role);
if (session?.user?.role === "admin") {
return;
}
@@ -69,6 +69,8 @@ const adminUserMap = process.env.ADMIN_USERS.split(",").reduce((result, entry) =
result.set(authType, s);
return result;
}, new Map());
console.log(adminUserMap);
console.log(process.env.ADMIN_USERS);
export const authOptions: AuthOptions = {
// Ensure we can store user data in a database.
@@ -97,6 +99,7 @@ export const authOptions: AuthOptions = {
where: { id: token.sub },
select: { role: true },
});
console.log("found role: " + role);
token.role = role;
return token;
},
@@ -118,6 +121,7 @@ export const authOptions: AuthOptions = {
// Update the database if the user is an admin.
if (adminForAccountType.has(account.providerAccountId)) {
console.log("updating admin");
await prisma.user.update({
data: {
role: "admin",