-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* home page styling and add view dashboard button * only return skeleton if data is not received yet * firebase jwt token in the user object * get sites added by the authenticated user * send token in swr mutate function * children type * install js-cookie * automatically redirect to dashboard if authed * set auth cookie * fix getStaticPaths * use incremental static regeneration for feedback * yarn upgrade * error handling in getStaticPaths
- Loading branch information
1 parent
494cb1e
commit 6ca977a
Showing
11 changed files
with
795 additions
and
780 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
import { NextApiRequest, NextApiResponse } from 'next' | ||
import { getAllSites } from '@/lib/firestore-admin' | ||
import { getUserSites } from '@/lib/firestore-admin' | ||
import admin from '@/lib/firebase-admin' | ||
|
||
export default async (_req: NextApiRequest, res: NextApiResponse) => { | ||
const { sites, error } = await getAllSites() | ||
|
||
if (error) { | ||
res.status(500).json({ error }) | ||
export default async (req: NextApiRequest, res: NextApiResponse) => { | ||
if (!req.headers.token) { | ||
return res.status(401).json({ error: 'Unauthorized' }) | ||
} | ||
|
||
res.status(200).json({ sites }) | ||
try { | ||
const { uid } = await admin.auth().verifyIdToken(req.headers.token as string) | ||
const sites = await getUserSites(uid) | ||
return res.status(200).json(sites) | ||
} catch (error) { | ||
return res.status(500).json({ error }) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6ca977a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: