google auth callback
parent
973fbea980
commit
1bfcc1abdc
|
@ -1 +1,29 @@
|
||||||
import { Request, Response } from "express";
|
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" });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import express from "express";
|
import express from "express";
|
||||||
|
import passport from "passport";
|
||||||
const router = express.Router();
|
const router = express.Router();
|
||||||
|
|
||||||
import * as calendarController from "../controllers/calendarController";
|
import * as calendarController from "../controllers/calendarController";
|
||||||
import passport from "passport";
|
|
||||||
|
|
||||||
router.get(
|
router.get(
|
||||||
"/auth/google",
|
"/auth/google",
|
||||||
|
@ -14,14 +14,16 @@ router.get(
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
|
router.get("/auth/google/callback", calendarController.GoogleAuthCallback);
|
||||||
|
/*
|
||||||
router.get(
|
router.get(
|
||||||
"/auth/google/callback",
|
"/auth/google/callback",
|
||||||
passport.authenticate("google", { failureRedirect: "/login" }),
|
passport.authenticate("google", { failureRedirect: "/login" }),
|
||||||
function (req, res) {
|
function (req, res) {
|
||||||
// Successful authentication, redirect home.
|
// Successful authentication, redirect home.
|
||||||
console.log("req.user", req.user);
|
console.log("req.user", req.user);
|
||||||
res.redirect("https://localhost:50127/s");
|
res.redirect("https://localhost:50127/");
|
||||||
}
|
}
|
||||||
);
|
); */
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|
|
@ -93,7 +93,7 @@ export function isStoreServiceActivityDescriptionValid(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isStoreServiceActivityPriceValid(
|
export function isStoreServiceActivityPriceValid(
|
||||||
storeServiceActivityPrice: any
|
storeServiceActivityPrice: number
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
storeServiceActivityPrice >= STORE_SERVICE_ACTIVITY_PRICE_MIN &&
|
storeServiceActivityPrice >= STORE_SERVICE_ACTIVITY_PRICE_MIN &&
|
||||||
|
@ -102,7 +102,7 @@ export function isStoreServiceActivityPriceValid(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isStoreServiceActivityDurationValid(
|
export function isStoreServiceActivityDurationValid(
|
||||||
storeServiceActivityDuration: any
|
storeServiceActivityDuration: number
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
storeServiceActivityDuration >= STORE_SERVICE_ACTIVITY_DURATION_MIN &&
|
storeServiceActivityDuration >= STORE_SERVICE_ACTIVITY_DURATION_MIN &&
|
||||||
|
|
Loading…
Reference in New Issue