mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-03 06:27:11 +01:00
fix all the formatting
This commit is contained in:
@@ -9,9 +9,13 @@ export const getServerSideProps = getServerSideRecentBookings
|
||||
|
||||
function AdminRecentBookings({ bookings }) {
|
||||
if (!bookings || !bookings.length) {
|
||||
return <Layout>
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">No recent bookings 😿</h3>
|
||||
</Layout>
|
||||
return (
|
||||
<Layout>
|
||||
<h3 className="text-lg leading-6 font-medium text-gray-900">
|
||||
No recent bookings 😿
|
||||
</h3>
|
||||
</Layout>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
@@ -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
|
||||
},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ import { createBill, patchBill } from '../../../../db/index'
|
||||
export default async function billHandler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
): Promise<void> {
|
||||
): Promise<void> {
|
||||
const {
|
||||
method,
|
||||
query: { uuid: uuids },
|
||||
|
||||
@@ -27,10 +27,10 @@ export default async function userHandler(
|
||||
}
|
||||
|
||||
try {
|
||||
const booking = await patchBooking(uuid, req.body);
|
||||
const booking = await patchBooking(uuid, req.body)
|
||||
res.status(200).json(booking)
|
||||
} catch (error) {
|
||||
console.error('failed patch booking', error);
|
||||
console.error('failed patch booking', error)
|
||||
res.status(400).end(`Failed to save booking: ${error.message}`)
|
||||
}
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user