db authentication replaced by Google

This commit is contained in:
2024-01-08 15:17:18 +01:00
parent 8367606493
commit e29d813aee
11 changed files with 58 additions and 223 deletions

View File

@@ -5,6 +5,8 @@ import { AddLocationButton } from './ui/AddLocationButton';
import clientPromise from './lib/mongodb';
import { BillingLocation } from './lib/db-types';
import { PageFooter } from './ui/PageFooter';
import { auth } from '@/app/lib/auth.google';
import { redirect } from 'next/navigation';
const getNextYearMonth = (yearMonth:number) => {
return(yearMonth % 100 === 12 ? yearMonth + 89 : yearMonth + 1);
@@ -12,9 +14,11 @@ const getNextYearMonth = (yearMonth:number) => {
export const Page = async () => {
const session = await auth();
const client = await clientPromise;
const db = client.db("rezije");
const locations = await db.collection<BillingLocation>("lokacije")
.find({})
.sort({ yearMonth: -1, name: 1 }) // sort by yearMonth descending
@@ -57,6 +61,13 @@ export const Page = async () => {
})
}
<PageFooter />
<ul>
<li>session.expires = { session?.expires }</li>
<li>session.user.id = { session?.user?.id }</li>
<li>session.user.email = { session?.user?.email }</li>
<li>session.user.name = { session?.user?.name }</li>
<li>session.user.image = { session?.user?.image }</li>
</ul>
</main>
);
}