Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
cbefec9
chore(config): move db connection and passport strategy to config folder
codewkaushik404 Jan 29, 2026
78dbc24
fix(schema): update user schema to support correct login and registra…
codewkaushik404 Jan 29, 2026
f2e5883
refactor(auth): replace passport-local-mongoose with manual auth impl…
codewkaushik404 Jan 29, 2026
ae0295f
feat(validation): add zod validation for auth routes with IIT Bhilai …
codewkaushik404 Jan 29, 2026
57c4189
feat(auth): add manual JWT authentication middleware
codewkaushik404 Jan 30, 2026
61dfd89
refactor(schema): update certificate schema
codewkaushik404 Jan 30, 2026
29bc583
feat(certificates): implement controller logic to create certificate …
codewkaushik404 Jan 30, 2026
a8b4d8e
feat(certificates): implement controller logic to create certificate …
codewkaushik404 Jan 30, 2026
82d3b70
feat(validation): add Zod schema to validate certificate batch creati…
codewkaushik404 Jan 30, 2026
bde7d5e
Fix crashes and ensure intended behavior
codewkaushik404 Jan 30, 2026
ecc1ebd
refactor(auth): split schemas into separate files and fix local auth …
codewkaushik404 Feb 9, 2026
8126097
refactor(auth, models, middleware): refactor code to ensure robust l…
codewkaushik404 Feb 9, 2026
4e96a8e
Refactored authentication logic and fixed related bugs.
codewkaushik404 Feb 17, 2026
d3c0261
Refactored authentication logic and fixed related bugs. Switched to s…
codewkaushik404 Feb 17, 2026
2a31781
refactor few segments
codewkaushik404 Feb 17, 2026
53d7216
fix: api responses to handle frontend requirements
codewkaushik404 Feb 17, 2026
cdf07e2
refactor
codewkaushik404 Feb 17, 2026
c342d2b
fix: imports for models in controllers according to the updated struc…
codewkaushik404 Feb 17, 2026
649fb09
fix: imports for models in controllers according to the updated struc…
codewkaushik404 Feb 17, 2026
3fe6ed8
refactor
codewkaushik404 Feb 17, 2026
f521062
refactor: streamline authentication and registration processes, enhan…
codewkaushik404 Feb 18, 2026
2ef2e05
fix: incorrect imports for models in routes.
codewkaushik404 Feb 19, 2026
0f47b6a
refactor: improve auth flow
codewkaushik404 Feb 19, 2026
0bd1220
feat: add certificate page and update navbar config for role-based ac…
codewkaushik404 Feb 19, 2026
ec6b13b
feat: add certificate page and update navbar config for role-based ac…
codewkaushik404 Feb 20, 2026
b726fc8
feat: implement request page components including Card, Requests, and…
codewkaushik404 Feb 20, 2026
56e25bf
feat: enhance authentication flow by handling fetch errors and updati…
codewkaushik404 Mar 4, 2026
7263443
chore(ui): revamp sidebar layout and component structure
codewkaushik404 Mar 4, 2026
7045720
fix: resolve CodeRabbit review comments and improve requests section UI
codewkaushik404 Mar 6, 2026
a41729a
feat: implement certificate batch creation and retrieval functionality
codewkaushik404 Mar 19, 2026
9eae2d6
feat: add template schema
codewkaushik404 Mar 19, 2026
a573f2c
feat: add full batch management UI with cards, modals, grids, and lists
codewkaushik404 Mar 19, 2026
6827589
feat: add batch and events service functions for API interactions
codewkaushik404 Mar 19, 2026
e142387
feat: remove certificates from navbar configuration
codewkaushik404 Mar 19, 2026
7691452
feat: implement templates management UI with filtering, creation, and…
codewkaushik404 Mar 19, 2026
0fd33ec
feat: implement certificate retrieval and add event and organization …
codewkaushik404 Mar 19, 2026
e774f14
chore: update backend seeding, validation, and error handling
codewkaushik404 Mar 19, 2026
47887db
feat: add BatchesPage, templatesPage and CertificatePage
codewkaushik404 Mar 19, 2026
e6cbe84
feat: add full batch management endpoints
codewkaushik404 Mar 20, 2026
e220ef9
feat: refactored batch-related UI components and create student panel
codewkaushik404 Mar 20, 2026
4283ada
feat(frontend): implement API service methods for create, edit, fetch…
codewkaushik404 Mar 20, 2026
1d9c799
feat: add approve,reject and approver edit batch APIs with frontend i…
codewkaushik404 Mar 21, 2026
f1a5147
refactor: update routes, APIs, hooks, and UI improvements
codewkaushik404 Mar 21, 2026
ba5cd5e
feat: add approve/reject and approver edit batch API services with up…
codewkaushik404 Mar 21, 2026
a9d0206
refactored codebase to resolve code rabbit raised issues
codewkaushik404 Mar 22, 2026
136facf
Merge remote-tracking branch 'upstream/main' into feature/certificate
codewkaushik404 Mar 22, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

cd frontend && npx lint-staged && cd ../backend && npx lint-staged
4 changes: 2 additions & 2 deletions backend/.env.example
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MONGODB_URI = mongodb://localhost:27017/cosadatabase
JWT_SECRET_TOKEN='secret-token'
FRONTEND_URL=http://localhost:3000
BACKEND_URL=http://localhost:5000
PORT=5000
BACKEND_URL=http://localhost:8000
PORT=8000

GOOGLE_CLIENT_ID=OAuth_Client_ID_from_google_cloud_console
GOOGLE_CLIENT_SECRET=OAuth_Client_Secret_from_google_cloud_console
Expand Down
6 changes: 2 additions & 4 deletions backend/db.js → backend/config/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ dotenv.config();
const connectDB = async () => {
try {
const ConnectDB = process.env.MONGODB_URI;
await mongoose.connect(ConnectDB, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
//Removing the options as they are no longer needed from mongoose6+
await mongoose.connect(ConnectDB);
console.log("MongoDB Connected");
} catch (error) {
console.error("MongoDB Connection Error:", error);
Expand Down
116 changes: 116 additions & 0 deletions backend/config/passportConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
const passport = require("passport");
const GoogleStrategy = require("passport-google-oauth20").Strategy;
const LocalStrategy = require("passport-local").Strategy;
const isIITBhilaiEmail = require("../utils/isIITBhilaiEmail");
const User = require("../models/userSchema");
const { loginValidate } = require("../utils/authValidate");
const bcrypt = require("bcrypt");
// Google OAuth Strategy
passport.use(
new GoogleStrategy(
{
clientID: process.env.GOOGLE_CLIENT_ID,
clientSecret: process.env.GOOGLE_CLIENT_SECRET,
callbackURL: `${process.env.BACKEND_URL}/auth/google/verify`, // Update with your callback URL
},
async (accessToken, refreshToken, profile, done) => {
// Check if the user already exists in your database
const email = profile.emails?.[0]?.value;
if (!email) {
//console.log("No email found in Google profile");
return done(null, false, { message: "Email not available from Google." });
}

if (!isIITBhilaiEmail(profile.emails[0].value)) {
console.log("Google OAuth blocked for: ", profile.emails[0].value);
return done(null, false, {
message: "Only @iitbhilai.ac.in emails are allowed.",
});
}
try {
const user = await User.findOne({ username: email });
//console.log("Looking for existing user with email:", email, "Found:", !!user);

if (user) {
// If user exists, return the user
//console.log("Returning existing user:", user.username);
return done(null, user);
}
// If user doesn't exist, create a new user in your database
const newUser = await User.create({
username: email,
role: "STUDENT",
strategy: "google",
personal_info: {
name: profile.displayName || "No Name",
email: email,
profilePic:
profile.photos && profile.photos.length > 0
? profile.photos[0].value
: "https://www.gravatar.com/avatar/?d=mp",
},
onboardingComplete: false,
});
//console.log("User is",newUser);
return done(null, newUser);
} catch (error) {
console.error("Error in Google strategy:", error);
return done(error);
}
},
),
);

//Local Strategy
passport.use(new LocalStrategy(async (username, password, done) => {

const result = loginValidate.safeParse({ username, password });

if (!result.success) {
let errors = result.error.issues.map((issue) => issue.message);
return done(null, false, {message: errors});
}

try{

const user = await User.findOne({ username });
if (!user) {
return done(null, false, {message: "Invalid user credentials"});
}


if (user.strategy !== "local" || !user.password) {
return done(null, false, { message: "Invalid login method" });
}

const isValid = await bcrypt.compare(password, user.password);
if (!isValid) {
return done(null, false, { message: "Invalid user credentials" });
}
return done(null, user);
}catch(err){
return done(err);
}

}));


//When login succeeds this will run
// serialize basically converts user obj into a format that can be transmitted(like a string, etc...)
// here take user obj and done callback and store only userId in session
passport.serializeUser((user, done) => {
done(null, user._id.toString());
});

//When a request comes in, take the stored id, fetch full user from DB, and attach it to req.user.
passport.deserializeUser(async (id, done) => {
try {
let user = await User.findById(id);
if(!user) return done(null, false);
done(null, user);
} catch (err) {
done(err, null);
}
});

module.exports = passport;
8 changes: 7 additions & 1 deletion backend/controllers/analyticsController.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
const {User, Achievement, UserSkill, Event, Position, PositionHolder,OrganizationalUnit}=require('../models/schema');
const mongoose = require("mongoose");
const getCurrentTenureRange = require('../utils/getTenureRange');

const User = require("../models/userSchema");
const Achievement = require("../models/achievementSchema");
const Position = require("../models/positionSchema");
const PositionHolder = require("../models/positionHolderSchema");
const OrganizationalUnit = require("../models/organizationSchema");
const Event = require("../models/eventSchema");
const { UserSkill } = require("../models/schema");

exports.getPresidentAnalytics= async (req,res) => {
try {
Expand Down
Loading