fix all the formatting

This commit is contained in:
Thomas Ruoff
2022-04-02 00:42:25 +02:00
parent 8e0648bf0f
commit 3c4f0efdc2
11 changed files with 79 additions and 59 deletions

View File

@@ -1,7 +1,7 @@
import { NextApiRequest, NextApiResponse } from 'next'
import NextAuth from 'next-auth'
import EmailProvider from 'next-auth/providers/email'
import GitHubProvider from "next-auth/providers/github";
import GitHubProvider from 'next-auth/providers/github'
import { MongoDBAdapter } from '@next-auth/mongodb-adapter'
import { MONGO_URI } from '../../../db'
@@ -10,7 +10,7 @@ import { MongoClient } from 'mongodb'
let client: MongoClient
const ADMIN_EMAIL = process.env.ADMIN_EMAIL
const GITHUB_USERS_GRANTED = ['111471'];
const GITHUB_USERS_GRANTED = ['111471']
async function getMongoClient() {
if (!client) {
@@ -28,7 +28,7 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
providers: [
GitHubProvider({
clientId: process.env.GITHUB_CLIENT_ID,
clientSecret: process.env.GITHUB_CLIENT_SECRET
clientSecret: process.env.GITHUB_CLIENT_SECRET,
}),
EmailProvider({
server: {
@@ -48,17 +48,17 @@ export default async function auth(req: NextApiRequest, res: NextApiResponse) {
if (account.provider === 'email') {
if (email.verificationRequest) {
// only allow admins by email entered
return account.providerAccountId === ADMIN_EMAIL;
return account.providerAccountId === ADMIN_EMAIL
}
// if user accesses with magic link, also only allow admin
return account.providerAccountId === ADMIN_EMAIL
} else if (account.provider === 'github') {
// only one and only one user
return GITHUB_USERS_GRANTED.includes(account.providerAccountId);
return GITHUB_USERS_GRANTED.includes(account.providerAccountId)
}
return false;
}
}
return false
},
},
})
}