Implemented Oauth
This commit is contained in:
@@ -1,11 +1,30 @@
|
||||
import express from 'express';
|
||||
import { applicantLogin, logout, validatorLogin } from '../controllers/authControllers.js';
|
||||
import express from "express";
|
||||
import {
|
||||
applicantLogin,
|
||||
logout,
|
||||
validatorLogin,
|
||||
googleAuthStart,
|
||||
googleAuthCallback,
|
||||
} from "../controllers/authControllers.js";
|
||||
import passport from "../services/passportService.js";
|
||||
|
||||
const router = express.Router();
|
||||
|
||||
router.post('/applicant-login', applicantLogin);
|
||||
router.post('/validator-login', validatorLogin);
|
||||
router.post("/applicant-login", applicantLogin);
|
||||
//this route is for google oauth, this one route will handle both applicantLogic and validatorLo
|
||||
// we will be passing the designation as a URL parameter ("validator" or "applicant") and it will be passed as state through OAuth
|
||||
router.get("/auth/oauth/:designation", googleAuthStart);
|
||||
//this will be the oauth callback Route
|
||||
router.get(
|
||||
"/auth/google/callback",
|
||||
passport.authenticate("google", {
|
||||
failureRedirect: "http://localhost:5173/?error=auth_failed",
|
||||
}),
|
||||
googleAuthCallback,
|
||||
);
|
||||
|
||||
router.get('/logout', logout)
|
||||
router.post("/validator", validatorLogin);
|
||||
|
||||
export default router;
|
||||
router.get("/logout", logout);
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user