having one solution for different components of app
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
// import { adminApp } from "../../../services/firebaseAdminService";
|
||||
import { getAuth } from "firebase/auth";
|
||||
import firebaseAdminAll, { credential } from "firebase-admin";
|
||||
|
||||
// todo do this here instead of cloud functions or just leave as is
|
||||
export default async function handler(
|
||||
req: NextApiRequest,
|
||||
res: NextApiResponse
|
||||
) {
|
||||
console.log(req.cookies);
|
||||
console.log(req.body);
|
||||
|
||||
if (!req.cookies.auth) {
|
||||
res.status(401).send({ reason: "not authorized" });
|
||||
return;
|
||||
}
|
||||
|
||||
// if (!verifiedToken) {
|
||||
// res.status(401).send({ reason: "auth token not valid" });
|
||||
// return;
|
||||
// }
|
||||
|
||||
res.status(200).json({ name: "John Doe" });
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
import fbAdm, { credential } from "firebase-admin";
|
||||
import firebaseAdmin, { App } from "firebase-admin/app";
|
||||
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
|
||||
// import serviceAccount from "../../../nirvana-for-business-firebase-adminsdk";
|
||||
|
||||
// const adminApp = firebaseAdmin.initializeApp({
|
||||
// credential: credential.cert({
|
||||
// privateKey: serviceAccount.private_key,
|
||||
// clientEmail: serviceAccount.client_email,
|
||||
// projectId: serviceAccount.project_id,
|
||||
// }),
|
||||
// });
|
||||
|
||||
// export default async function(req: NextApiRequest, res: NextApiResponse) {
|
||||
// console.log('Validating token...');
|
||||
|
||||
// try {
|
||||
// const { token } = JSON.parse(req.headers.authorization || '{}');
|
||||
// if (!token) {
|
||||
// return res.status(403).send({
|
||||
// errorCode: 403,
|
||||
// message: 'Auth token missing.'
|
||||
// });
|
||||
// }
|
||||
|
||||
// const verifiedToken = fbAdm.auth().verifyIdToken(token)
|
||||
|
||||
// return res.status(200).send(verifiedToken);
|
||||
// } catch (err) {
|
||||
// return res.status(err.code).send({
|
||||
// errorCode: err.code,
|
||||
// message: err.message,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
export {};
|
||||
@@ -0,0 +1,5 @@
|
||||
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
|
||||
|
||||
export default function handler(req, res) {
|
||||
res.status(200).json({ name: 'John Doe' })
|
||||
}
|
||||
Reference in New Issue
Block a user