google auth callback

main
alex 2024-01-13 23:45:20 +01:00
parent 973fbea980
commit 1bfcc1abdc
3 changed files with 35 additions and 5 deletions

View File

@ -1 +1,29 @@
import { Request, Response } from "express";
import logger from "../logger/logger";
export async function GoogleAuthCallback(req: Request, res: Response) {
try {
const { code } = req.query;
if (!code) {
return res.status(400).send({ err: "invalid request" });
}
logger.debug("Google auth callback with code: %s", code);
// get access token from google
// get user info from google
// check if user exists in db
// if user exists, create session
// if user doesn't exist, create user and session
// redirect to home page
res.redirect("https://localhost:50127/");
} catch (error) {
res.status(500).send({ err: "invalid request" });
}
}

View File

@ -1,8 +1,8 @@
import express from "express";
import passport from "passport";
const router = express.Router();
import * as calendarController from "../controllers/calendarController";
import passport from "passport";
router.get(
"/auth/google",
@ -14,14 +14,16 @@ router.get(
})
);
router.get("/auth/google/callback", calendarController.GoogleAuthCallback);
/*
router.get(
"/auth/google/callback",
passport.authenticate("google", { failureRedirect: "/login" }),
function (req, res) {
// Successful authentication, redirect home.
console.log("req.user", req.user);
res.redirect("https://localhost:50127/s");
res.redirect("https://localhost:50127/");
}
);
); */
export default router;

View File

@ -93,7 +93,7 @@ export function isStoreServiceActivityDescriptionValid(
}
export function isStoreServiceActivityPriceValid(
storeServiceActivityPrice: any
storeServiceActivityPrice: number
) {
return (
storeServiceActivityPrice >= STORE_SERVICE_ACTIVITY_PRICE_MIN &&
@ -102,7 +102,7 @@ export function isStoreServiceActivityPriceValid(
}
export function isStoreServiceActivityDurationValid(
storeServiceActivityDuration: any
storeServiceActivityDuration: number
) {
return (
storeServiceActivityDuration >= STORE_SERVICE_ACTIVITY_DURATION_MIN &&