Skip to content
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
24 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
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
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
67 changes: 67 additions & 0 deletions backend/config/passportConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const passport = require("passport");
const GoogleStrategy = require("passport-google-oauth20").Strategy;
const isIITBhilaiEmail = require("../utils/isIITBhilaiEmail");
const User = require("../models/userSchema");

// 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
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.",
});
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
try {
const user = await User.findOne({ username: profile.emails[0].value });

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

await newUser.save();
return done(null, newUser);
} catch (error) {
return done(error);
}
},
),
);

passport.serializeUser((user, done) => {
done(null, user);
});

passport.deserializeUser(async (userKey, done) => {
try {
let user = await User.findById(userKey._id);
done(null, user);
} catch (err) {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
done(err);
}
});

module.exports = passport;
58 changes: 58 additions & 0 deletions backend/models/achievementSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
const mongoose = require("mongoose");
//achievements collection
const achievementSchema = new mongoose.Schema({
achievement_id: {
type: String,
required: true,
unique: true,
},
user_id: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
},
title: {
type: String,
required: true,
},
description: String,
category: {
type: String,
required: true,
},
type: {
type: String,
},
level: {
type: String,
},
date_achieved: {
type: Date,
required: true,
},
position: {
type: String,
},
event_id: {
type: mongoose.Schema.Types.ObjectId,
ref: "Event",
default: null, // optional
},
certificate_url: String,
verified: {
type: Boolean,
default: false,
},
verified_by: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
default: null,
},
created_at: {
type: Date,
default: Date.now,
},
});

const Achievement = mongoose.model("Achievement", achievementSchema);
module.exports = Achievement;
118 changes: 118 additions & 0 deletions backend/models/eventSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
const mongoose = require("mongoose");

//events collection
const eventSchema = new mongoose.Schema({
event_id: {
type: String,
required: true,
unique: true,
},
title: {
type: String,
required: true,
},
description: String,
category: {
type: String,
enum: ["cultural", "technical", "sports", "academic", "other"],
},
type: {
type: String,
},
organizing_unit_id: {
type: mongoose.Schema.Types.ObjectId,
ref: "Organizational_Unit",
required: true,
},
organizers: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
],
schedule: {
start: Date,
end: Date,
venue: String,
mode: {
type: String,
enum: ["online", "offline", "hybrid"],
},
},
registration: {
required: Boolean,
start: Date,
end: Date,
fees: Number,
max_participants: Number,
},
budget: {
allocated: Number,
spent: Number,
sponsors: [
{
type: String,
},
],
},
status: {
type: String,
enum: ["planned", "ongoing", "completed", "cancelled"],
default: "planned",
},
participants: [
{
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
],
winners: [
{
user: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
position: String, // e.g., "1st", "2nd", "Best Speaker", etc.
},
],
feedback_summary: {
type: Object, // You can define structure if fixed
},
media: {
images: [String],
videos: [String],
documents: [String],
},
room_requests: [
{
date: { type: Date, required: true },
time: { type: String, required: true },
room: { type: String, required: true },
description: { type: String },
status: {
type: String,
enum: ["Pending", "Approved", "Rejected"],
default: "Pending",
},
requested_at: {
type: Date,
default: Date.now,
},
reviewed_by: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
},
},
],
created_at: {
type: Date,
default: Date.now,
},
updated_at: {
type: Date,
default: Date.now,
},
});

const Event = mongoose.model("Event", eventSchema);
module.exports = Event;
69 changes: 69 additions & 0 deletions backend/models/feedbackSchema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const mongoose = require("mongoose");

//feedback collection
const feedbackSchema = new mongoose.Schema({
feedback_id: {
type: String,
required: true,
unique: true,
},
type: {
type: String,
required: true,
},
target_id: {
type: mongoose.Schema.Types.ObjectId,
//required: true,
// We'll dynamically interpret this field based on target_type
},
target_type: {
type: String,
required: true,
},
feedback_by: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
required: true,
},
// category: {
// type: String,
// enum: ['organization', 'communication', 'leadership'],
// required: true
// },
rating: {
type: Number,
min: 1,
max: 5,
},
comments: {
type: String,
},
is_anonymous: {
type: Boolean,
default: false,
},
is_resolved: {
type: Boolean,
default: false,
},
actions_taken: {
type: String,
default: "",
},
created_at: {
type: Date,
default: Date.now,
},
resolved_at: {
type: Date,
default: null,
},
resolved_by: {
type: mongoose.Schema.Types.ObjectId,
ref: "User",
default: null,
},
});

const Feedback = mongoose.model("Feedback", feedbackSchema);
module.exports = Feedback;
Loading