oauth
parent
1bfcc1abdc
commit
b1cc565c60
|
@ -1,29 +1,2 @@
|
|||
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" });
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,16 +14,19 @@ router.get(
|
|||
})
|
||||
);
|
||||
|
||||
router.get("/auth/google/callback", calendarController.GoogleAuthCallback);
|
||||
/*
|
||||
router.get(
|
||||
"/auth/google/callback",
|
||||
passport.authenticate("google", { failureRedirect: "/login" }),
|
||||
passport.authenticate("google", {
|
||||
failureRedirect:
|
||||
"https://customerdashboard.ex.umbach.dev/store/calendar/failed",
|
||||
}),
|
||||
function (req, res) {
|
||||
// Successful authentication, redirect home.
|
||||
console.log("req.user", req.user);
|
||||
res.redirect("https://localhost:50127/");
|
||||
res.redirect(
|
||||
"https://customerdashboard.ex.umbach.dev/store/calendar/finish"
|
||||
);
|
||||
}
|
||||
); */
|
||||
);
|
||||
|
||||
export default router;
|
||||
|
|
Loading…
Reference in New Issue