Implemented Oauth

This commit is contained in:
2026-01-02 00:36:24 +05:30
parent 933c0741ab
commit 0130f746b0
22 changed files with 960 additions and 257 deletions

View File

@@ -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;