diff --git a/server/index.js b/server/index.js index 88cd5b592..53a68b06e 100644 --- a/server/index.js +++ b/server/index.js @@ -6,7 +6,7 @@ import cors from "cors"; import csrf from 'csurf'; import * as dotenv from "dotenv"; dotenv.config(); - +import initializePassport from './src/api/middlewares/passportConfig.js' const PORT = process.env.PORT || 5000; const CONNECTION_URI = process.env.MONGODB_URI; @@ -17,12 +17,18 @@ app.use(bodyParser.json({ limit: "30mb", extended: true })); app.use(bodyParser.urlencoded({ limit: "30mb", extended: true })); app.use(cors()); + +initializePassport(app) + + + import indexRoute from "./src/api/routes/index.js"; import testRoute from "./src/api/routes/test.js"; import user from "./src/api/routes/user.js"; import profile from "./src/api/routes/profile.js"; import event from "./src/api/routes/events.js"; -import userAdmin from "./src/api/routes/userAdmin.js"; +import googleAuth from "./src/api/routes/googleAuth.js" + //rate limiter @@ -43,8 +49,8 @@ app.use("/test", testRoute) app.use("/user", user) app.use("/profile", profile) app.use("/event", event) +app.use("/auth",googleAuth) -app.use("/userAdmin", userAdmin) app.use(csrf) diff --git a/server/package-lock.json b/server/package-lock.json index eb94b2a2b..790d805b8 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -21,7 +21,9 @@ "mongoose": "^7.4.2", "mongoose-sanitizer": "^1.0.0", "nodemailer": "^6.9.5", - "nodemon": "^3.0.1" + "nodemon": "^3.0.1", + "passport": "^0.6.0", + "passport-google-oauth20": "^2.0.0" }, "devDependencies": { "@vercel/ncc": "^0.36.1" @@ -364,6 +366,14 @@ "node": ">=0.10.0" } }, + "node_modules/base64url": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/base64url/-/base64url-3.0.1.tgz", + "integrity": "sha512-ir1UPr3dkwexU7FdV8qBBbNDRUhMmIekYMFZfi+C/sLNnRESKPl23nB9b2pltqfOQNnGzsDdId90AEtG5tCx4A==", + "engines": { + "node": ">=6.0.0" + } + }, "node_modules/bcrypt": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.1.tgz", @@ -3689,6 +3699,11 @@ "set-blocking": "^2.0.0" } }, + "node_modules/oauth": { + "version": "0.9.15", + "resolved": "https://registry.npmjs.org/oauth/-/oauth-0.9.15.tgz", + "integrity": "sha512-a5ERWK1kh38ExDEfoO6qUHJb32rd7aYmPHuyCu3Fta/cnICvYmgd2uhuKXvPD+PXB+gCEYYEaQdIRAjCOwAKNA==" + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -3926,6 +3941,61 @@ "node": ">=0.10.0" } }, + "node_modules/passport": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/passport/-/passport-0.6.0.tgz", + "integrity": "sha512-0fe+p3ZnrWRW74fe8+SvCyf4a3Pb2/h7gFkQ8yTJpAO50gDzlfjZUZTO1k5Eg9kUct22OxHLqDZoKUWRHOh9ug==", + "dependencies": { + "passport-strategy": "1.x.x", + "pause": "0.0.1", + "utils-merge": "^1.0.1" + }, + "engines": { + "node": ">= 0.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jaredhanson" + } + }, + "node_modules/passport-google-oauth20": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/passport-google-oauth20/-/passport-google-oauth20-2.0.0.tgz", + "integrity": "sha512-KSk6IJ15RoxuGq7D1UKK/8qKhNfzbLeLrG3gkLZ7p4A6DBCcv7xpyQwuXtWdpyR0+E0mwkpjY1VfPOhxQrKzdQ==", + "dependencies": { + "passport-oauth2": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + } + }, + "node_modules/passport-oauth2": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/passport-oauth2/-/passport-oauth2-1.7.0.tgz", + "integrity": "sha512-j2gf34szdTF2Onw3+76alNnaAExlUmHvkc7cL+cmaS5NzHzDP/BvFHJruueQ9XAeNOdpI+CH+PWid8RA7KCwAQ==", + "dependencies": { + "base64url": "3.x.x", + "oauth": "0.9.x", + "passport-strategy": "1.x.x", + "uid2": "0.0.x", + "utils-merge": "1.x.x" + }, + "engines": { + "node": ">= 0.4.0" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/jaredhanson" + } + }, + "node_modules/passport-strategy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz", + "integrity": "sha512-CB97UUvDKJde2V0KDWWB3lyf6PC3FaZP7YxZ2G8OAtn9p4HI9j9JLP9qjOGZFvyl8uwNT8qM+hGnz/n16NI7oA==", + "engines": { + "node": ">= 0.4.0" + } + }, "node_modules/path-is-absolute": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", @@ -3963,6 +4033,11 @@ "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" }, + "node_modules/pause": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz", + "integrity": "sha512-KG8UEiEVkR3wGEb4m5yZkVCzigAD+cVEJck2CzYZO37ZGJfctvVptVO192MwrtPhzONn6go8ylnOdMhKqi4nfg==" + }, "node_modules/picomatch": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", @@ -5128,6 +5203,11 @@ "node": ">= 0.8" } }, + "node_modules/uid2": { + "version": "0.0.4", + "resolved": "https://registry.npmjs.org/uid2/-/uid2-0.0.4.tgz", + "integrity": "sha512-IevTus0SbGwQzYh3+fRsAMTVVPOoIVufzacXcHPmdlle1jUpq7BRL+mw3dgeLanvGZdwwbWhRV6XrcFNdBmjWA==" + }, "node_modules/unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", diff --git a/server/package.json b/server/package.json index e20a996c4..22788ff53 100644 --- a/server/package.json +++ b/server/package.json @@ -23,7 +23,9 @@ "mongoose": "^7.4.2", "mongoose-sanitizer": "^1.0.0", "nodemailer": "^6.9.5", - "nodemon": "^3.0.1" + "nodemon": "^3.0.1", + "passport": "^0.6.0", + "passport-google-oauth20": "^2.0.0" }, "devDependencies": { "@vercel/ncc": "^0.36.1" diff --git a/server/src/api/controllers/changePassword.js b/server/src/api/controllers/changePassword.js index b573bbef1..9df5e677d 100644 --- a/server/src/api/controllers/changePassword.js +++ b/server/src/api/controllers/changePassword.js @@ -1,9 +1,5 @@ import bcrypt from 'bcrypt' -import userAdminModel from '../models/userAdminModel.js' -import userStudentModel from '../models/userStudentModel.js' -import userFacultyModel from '../models/userFacultyModel.js' -import userStaffModel from '../models/userStaffModel.js' -import userVisitorModel from '../models/userVisitorModel.js' +import userModel from "../models/userModel.js" diff --git a/server/src/api/controllers/deleteUser.js b/server/src/api/controllers/deleteUser.js index 387bbbb27..7cb5bf570 100644 --- a/server/src/api/controllers/deleteUser.js +++ b/server/src/api/controllers/deleteUser.js @@ -1,8 +1,4 @@ -import userAdminModel from "../models/userAdminModel.js" -import userStudentModel from "../models/userStudentModel.js" -import userStaffModel from "../models/userStaffModel.js" -import userFacultyModel from "../models/userFacultyModel.js" -import userVisitorModel from "../models/userVisitorModel.js" +import userModel from "../models/userModel.js" import bcrypt from 'bcrypt' diff --git a/server/src/api/controllers/forgotPassword.js b/server/src/api/controllers/forgotPassword.js index 336cce789..bfb49d050 100644 --- a/server/src/api/controllers/forgotPassword.js +++ b/server/src/api/controllers/forgotPassword.js @@ -1,8 +1,4 @@ -import userAdminModel from "../models/userAdminModel.js"; -import userStudentModel from "../models/userStudentModel.js"; -import userStaffModel from "../models/userStaffModel.js"; -import userFacultyModel from "../models/userFacultyModel.js"; -import userVisitorModel from "../models/userVisitorModel.js"; +import userModel from "../models/userModel.js" import bcrypt from 'bcrypt'; import jwt from 'jsonwebtoken' import sendEmail from '../middlewares/sendEmail.js' diff --git a/server/src/api/controllers/googleAuth.js b/server/src/api/controllers/googleAuth.js new file mode 100644 index 000000000..22fc3d2e1 --- /dev/null +++ b/server/src/api/controllers/googleAuth.js @@ -0,0 +1,53 @@ +import '../middlewares/passportConfig.js' +import passport from 'passport' +import generateToken from "../middlewares/generateToken.js"; + + + +/** + * Route: /auth/google + * Desc: Open google consent screen + */ +export const authGoogle = passport.authenticate('google', { scope: [ 'email', 'profile' ]}) + + + +/** + * Route: /auth/google/callback + * Desc: handle callback from google + */ +export const callbackGoogle = passport.authenticate('google', { successRedirect: '/auth/protected', failureRedirect: '/auth/failed' }) + + + +/** + * Route /protected + * desc: reditrection after successfull + * google auth with userdata in req + */ +export const authenticated = (req, res)=>{ + // let name = req.user.displayName + + const SECRET = process.env.USER_SECRET + const token = generateToken(req.user, SECRET); + + req.session.user = { + token: token, + user: req.user + } + + res.status(200).json({ + success: true, + user: req.user, + token: token + }) +} + + +/** + * Route: /failed + * Desc: Redirection if google authentication failed + */ +export const failed = (req, res)=>{ + res.status(401).send("google authentication failed") +} \ No newline at end of file diff --git a/server/src/api/controllers/userAdmin.js b/server/src/api/controllers/userAdmin.js deleted file mode 100644 index e7f034c19..000000000 --- a/server/src/api/controllers/userAdmin.js +++ /dev/null @@ -1,201 +0,0 @@ -import userAdminModel from "../models/userAdminModel.js" -import bcrypt from 'bcrypt' -import generateToken from "../middlewares/generateToken.js" -import * as dotenv from "dotenv"; -dotenv.config(); - -/** - * Route: /userAdmin - * Desc: to show or access user Admin - */ -export const userAdmin = async (req, res) => { - res.status(200).json({message:"Show user Admin signin/signup page"}) - -} - - - -/** - * Route: /userAdmin/signup - * Desc: Admin user sign up - */ -export const signup = async (req, res) => { - const { name, email, password, confirmPassword} = req.body - - - //check if any field is not empty - if (!name || !email || !password || !confirmPassword) { - return res.status(404).json({ - success: false, - message: "Please Fill all the Details.", - }); - } - - //password and email constrains - const passwordRegex = - /^(?=.*[a-z])(?=.*[A-Z])(?=.*[@$%#^&*])(?=.*[0-9]).{8,}$/; - - const emailDomains = [ - "@gmail.com", - "@yahoo.com", - "@hotmail.com", - "@aol.com", - "@outlook.com", - ]; - - - - //check name length - if (name.length < 2) { - return res - .status(404) - .json({ - success: false, - msg: "Name must be atleast 2 characters long." }); - } - - - - // check email format - if (!emailDomains.some((v) => email.indexOf(v) >= 0)) { - return res.status(404).json({ - success: false, - msg: "Please enter a valid email address", - })}; - - - // check password format - if (!passwordRegex.test(password)) { - return res.status(404).json({ - success: false, - msg: "Password must be at least 8 characters long and include at least 1 uppercase letter, 1 lowercase letter, 1 symbol (@$%#^&*), and 1 number (0-9)", - }); - } - - - // check password match - if(password != confirmPassword){ - - res.json({ - success: false, - msg:"Password does not match"}) - } - - - - /** - * checking field types - * to avoid sql attacks - */ - if (typeof name !== "string" && name !== undefined) { - res.status(400).json({ status: "error" }); - return; - } - - if (typeof email !== "string" && email !== undefined) { - res.status(400).json({ status: "error" }); - return; - } - - if (typeof password !== "string" || typeof confirmPassword !== "string") { - res.status(400).json({ status: "error" }); - return; - } - - - const oldUser = await userAdminModel.findOne({ email }); - try{ - if(!oldUser){ - - - // hash password with bcrypt - const hashedPassword = await bcrypt.hash(password, 12) - - // create userAdmin in database - const result = userAdminModel.create({ - name, - email, - password: hashedPassword, - }); - - if(result){ - res.json({ - success: true, - msg: "User Added Successfully !"}) - } - } - else{ - res.json({ - success: false, - msg: "user already exist"}) - } - } - catch(err){ - console.log(err) - } - -} - - - - -/** - * Route: /userAdmin/signin - * Desc: user admin sign in - */ -export const signin = async (req, res) => { - const {email, password} = req.body - - const oldUser = await userAdminModel.findOne({email}) - - const SECRET = process.env.ADMIN_SECRET - - if(oldUser){ - - const isPasswordCorrect = await bcrypt.compare(password, oldUser.password); - - if(isPasswordCorrect){ - - const token = generateToken(oldUser, SECRET); - - req.session.user = { - token: token, - user: oldUser - } - - console.log(oldUser) - res.status(200).json({ - success: true, - result: oldUser.name, - token, - // csrfToken: req.csrfToken, - msg: "Admin is logged in successfully" - }); - - } - else{ - req.session.destroy(err => { - if (err) { - console.error("Error destroying session:", err); - res.status(500).send("Internal Server Error"); - } - }); - res.json({ msg: "Incorrect password" }) - } - } - else{ - req.session.destroy(err => { - if (err) { - console.error("Error destroying session:", err); - res.status(500).send("Internal Server Error"); - } - }); - res.json({ msg:"User Admin does not exist" }) - } -} - - - - - - diff --git a/server/src/api/middlewares/passportConfig.js b/server/src/api/middlewares/passportConfig.js new file mode 100644 index 000000000..76b6b919d --- /dev/null +++ b/server/src/api/middlewares/passportConfig.js @@ -0,0 +1,73 @@ +import passport from 'passport' +import { Strategy as GoogleStrategy } from 'passport-google-oauth20' +import * as dotenv from "dotenv"; +dotenv.config(); +import userModel from '../models/userModel.js'; +import session from 'express-session'; + + +const initializePassport = (app) => { + app.use( + session({ + secret: process.env.SESSION_SECRET, + resave: false, + saveUninitialized: true + }) + ); + + app.use(passport.initialize()); + app.use(passport.session()); + + + + passport.use(new GoogleStrategy({ + clientID: process.env.CLIENT_ID, + clientSecret: process.env.CLIENT_SECRET, + callbackURL: process.env.BASE_URL+'/auth/google/callback' + }, + async (accessToken, refreshToken, profile, done) => { + // Handle user data and pass it to the 'done' callback + // Typically, you would save user data to your database here + try { + + let User = await userModel.findOne({ googleId: profile.id }); + + // If user already exists, return the user + if (User) { + return done(null, User); + } + + // If user does not exist, create a new user record + const result = await userModel.create({ + googleId: profile.id, + name: profile.displayName, + email: profile.emails[0].value, + }); + if(result){ + console.log("user created"+ result) + } + + let newUser = await userModel.findOne({ googleId: profile.id }) + + return done(null, newUser); + } + catch(err){ + return done(err); + } + } +)); + +passport.serializeUser((user, done )=>{ + done(null, user) +}) + +passport.deserializeUser((user, done) => { + done(null, user) +}) + + +} + + + +export default initializePassport; diff --git a/server/src/api/models/userAdminModel.js b/server/src/api/models/userAdminModel.js deleted file mode 100644 index 466770911..000000000 --- a/server/src/api/models/userAdminModel.js +++ /dev/null @@ -1,19 +0,0 @@ -import mongoose from "mongoose"; -import sanitizerPlugin from 'mongoose-sanitizer' - - -//estimated admin schema -const userAdminModel = new mongoose.Schema({ - id: { type: String }, - name: { type: String, required: true }, - email: { type: String, required: true }, - password: { type: String, required: true }, - role: { type: String, default: 'admin'}, -}); - -// sanitize schema -userAdminModel.plugin(sanitizerPlugin); - - - -export default mongoose.model("userAdmins", userAdminModel); diff --git a/server/src/api/models/userFacultyModel.js b/server/src/api/models/userFacultyModel.js deleted file mode 100644 index 353e38feb..000000000 --- a/server/src/api/models/userFacultyModel.js +++ /dev/null @@ -1,25 +0,0 @@ -import mongoose from "mongoose"; -import sanitizerPlugin from 'mongoose-sanitizer' - -//estimated student schema -const userFacultyModel = mongoose.Schema({ - id: { type: String }, - name: { type: String, required: true }, - email: { type: String, required: true }, - password: { type: String, required: true }, - branch: { type: String, required: true }, - subjects: { type: String, required: true }, - designation: { type: String, required: true }, - education: { type: String, required: true }, - role: { type: String, default: 'faculty'}, - bio: { type: String }, - intrest: { type: String }, - mobile: { type: String} -}) - - -// sanitize schema -userFacultyModel.plugin(sanitizerPlugin); - - -export default mongoose.model("userFaculties",userFacultyModel); \ No newline at end of file diff --git a/server/src/api/models/userModel.js b/server/src/api/models/userModel.js index 5e9b27ac0..833a4476e 100644 --- a/server/src/api/models/userModel.js +++ b/server/src/api/models/userModel.js @@ -4,11 +4,12 @@ import sanitizerPlugin from 'mongoose-sanitizer' // User schema const userModel = mongoose.Schema({ id: { type: String }, + googleId: { type: String }, name: { type: String }, collegeEmail: { type: String }, email: { type: String, required: true }, - password: { type: String, required: true }, - role: { type: String, default: 'faculty'}, + password: { type: String }, + role: { type: String }, branch: { type: String }, subjects: { type: String }, designation: { type: String }, diff --git a/server/src/api/models/userStaffModel.js b/server/src/api/models/userStaffModel.js deleted file mode 100644 index cf52a8b59..000000000 --- a/server/src/api/models/userStaffModel.js +++ /dev/null @@ -1,23 +0,0 @@ -import mongoose from "mongoose"; -import sanitizerPlugin from 'mongoose-sanitizer' - - -//estimated staff schema -const userStaffModel = mongoose.Schema({ - id: { type: String }, - name: { type: String, required: true }, - branch: { type: String, required: true }, - email: { type: String, required: true }, - password: { type: String, required: true }, - designation: { type: String, required: true }, - role: { type: String, default: 'staff'}, - bio: { type: String }, - mobile: { type: Number } - -}) - - -// sanitize schema -userStaffModel.plugin(sanitizerPlugin); - -export default mongoose.model("userStaffs",userStaffModel); \ No newline at end of file diff --git a/server/src/api/models/userStudentModel.js b/server/src/api/models/userStudentModel.js deleted file mode 100644 index 1c3daee7c..000000000 --- a/server/src/api/models/userStudentModel.js +++ /dev/null @@ -1,22 +0,0 @@ -import mongoose from "mongoose"; -import sanitizerPlugin from 'mongoose-sanitizer' - -//estimated student schema -const userStudentModel = mongoose.Schema({ - id: { type: String }, - name: { type: String, required: true }, - email: { type: String, required: true }, - password: { type: String, required: true }, - year: { type: String, required: true }, - role: { type: String, default: 'student'}, - branch: { type: String }, - intrest: {type: String}, - enrollNo: { type: Number }, - mobile: { type: Number } - -}) - -// sanitize schema -userStudentModel.plugin(sanitizerPlugin); - -export default mongoose.model("userStudents",userStudentModel); \ No newline at end of file diff --git a/server/src/api/models/userVisitorModel.js b/server/src/api/models/userVisitorModel.js deleted file mode 100644 index 55506f08b..000000000 --- a/server/src/api/models/userVisitorModel.js +++ /dev/null @@ -1,18 +0,0 @@ -import mongoose from "mongoose"; -import sanitizerPlugin from 'mongoose-sanitizer' - -//estimated visitor schema -const userVisitorModel = mongoose.Schema({ - id: { type: String }, - name: { type: String, required: true }, - email: { type: String, required: true }, - password: { type: String, required: true }, - role: { type: String, default: 'visitor'}, - bio: { type: String }, -}) - - -// sanitize schema -userVisitorModel.plugin(sanitizerPlugin); - -export default mongoose.model("userVisitors", userVisitorModel); \ No newline at end of file diff --git a/server/src/api/routes/googleAuth.js b/server/src/api/routes/googleAuth.js new file mode 100644 index 000000000..41a2c3e25 --- /dev/null +++ b/server/src/api/routes/googleAuth.js @@ -0,0 +1,10 @@ +import express from 'express'; +const router = express.Router(); +import { authGoogle, callbackGoogle, authenticated, failed } from '../controllers/googleAuth.js' + + +router.get('/google',authGoogle) +router.get('/google/callback', callbackGoogle) +router.get('/protected', authenticated) +router.get('/failed', failed) +export default router; diff --git a/server/src/api/routes/userAdmin.js b/server/src/api/routes/userAdmin.js deleted file mode 100644 index bd45755df..000000000 --- a/server/src/api/routes/userAdmin.js +++ /dev/null @@ -1,15 +0,0 @@ -import express from 'express'; -import session from '../middlewares/session.js' -import {csrfProtect} from '../middlewares/csrfProtection.js'; - -const router = express.Router(); - -import {userAdmin, signup, signin} from "../controllers/userAdmin.js"; - - -router.get("/", userAdmin) -router.post("/signup", signup) -router.post("/signin", session, signin) -// router.post("/signin", session, csrfProtect, signin) - -export default router; \ No newline at end of file diff --git a/server/src/api/routes/userFaculty.js b/server/src/api/routes/userFaculty.js deleted file mode 100644 index f2a7944d4..000000000 --- a/server/src/api/routes/userFaculty.js +++ /dev/null @@ -1,14 +0,0 @@ -import express from 'express'; -import session from '../middlewares/session.js' -import {csrfProtect} from '../middlewares/csrfProtection.js'; - -const router = express.Router(); - -// import {userFaculty, signup, signin} from "../controllers/userFaculty.js"; - - -// router.get("/", userFaculty) -// router.post("/signup", signup) -// router.post("/signin", session, csrfProtect, signin) - -export default router; \ No newline at end of file diff --git a/server/src/api/routes/userStaff.js b/server/src/api/routes/userStaff.js deleted file mode 100644 index 0f123019d..000000000 --- a/server/src/api/routes/userStaff.js +++ /dev/null @@ -1,14 +0,0 @@ -import express from 'express'; -import session from '../middlewares/session.js' -import {csrfProtect} from '../middlewares/csrfProtection.js'; - -const router = express.Router(); - -import {userStaff, signup, signin} from "../controllers/userStaff.js"; - - -router.get("/", userStaff) -router.post("/signup", signup) -router.post("/signin", session, csrfProtect, signin) - -export default router; \ No newline at end of file diff --git a/server/src/api/routes/userStudent.js b/server/src/api/routes/userStudent.js deleted file mode 100644 index 8bda03891..000000000 --- a/server/src/api/routes/userStudent.js +++ /dev/null @@ -1,13 +0,0 @@ -import express from 'express'; -const router = express.Router(); -import session from '../middlewares/session.js'; -import {csrfProtect} from '../middlewares/csrfProtection.js'; - -import {userStudent, signup, signin} from "../controllers/userStudent.js"; - - -router.get("/", userStudent) -router.post("/signup", signup) -router.post("/signin", session, csrfProtect, signin) - -export default router; \ No newline at end of file diff --git a/server/src/api/routes/userVisitor.js b/server/src/api/routes/userVisitor.js deleted file mode 100644 index 88d2921e5..000000000 --- a/server/src/api/routes/userVisitor.js +++ /dev/null @@ -1,14 +0,0 @@ -import express from 'express'; -import session from '../middlewares/session.js' -import {csrfProtect} from '../middlewares/csrfProtection.js'; - -const router = express.Router(); - -import {userVisitor, signup, signin} from "../controllers/userVisitor.js"; - - -router.get("/", userVisitor) -router.post("/signup", signup) -router.post("/signin", session, csrfProtect, signin) - -export default router; \ No newline at end of file