Skip to content
SaifAlotaibie edited this page Feb 1, 2025 · 8 revisions

Welcome to the Student-Club-Management-System wiki !

# Overview

The Student Club Management System is a web-based platform that allows students and club administrators to manage events, memberships, and communications efficiently. It centralizes all club-related activities, making it easier for students to stay updated and participate in university events.

# Key Features:

  • Club registration and management.
  • Event creation and tracking.
  • Member management and user authentication.
  • Role-based access for admins and students.

# Setup Instructions

Prerequisites Make sure you have the following installed: Node.js (v16 or later) MongoDB Git

# Technology | Purpose

-- | -- Node.js | Backend development Express.js | Web framework for Node.js MongoDB | Database for storing users, clubs, and events Mongoose | ODM for MongoDB EJS | Templating engine for rendering dynamic pages Bootstrap | Frontend styling Passport.js | User authentication via Google & GitHub Git & GitHub | Version control & team collaboration

# GET Requests (Fetching Data & Redirects) (auth.js)

  • Authentication Requests (/auth/google & /auth/github)

  • These routes initiate the login process by redirecting users to Google or GitHub for authentication.

  • They specify the scope of permissions (e.g., profile, email).

  • Callback Routes (/google/callback & /github/callback)

  • Once the user logs in successfully, they are redirected back to the app.

  • Passport.js processes their profile, checks if they exist in the database, and either:

  • Logs them in if they already exist.

  • Creates a new user account if it's their first time logging in.

  • If login fails, the user is sent to a failure page (/login-failure).

  • Login Page (/login)

  • Serves the HTML login page where users can choose their authentication method (Google/GitHub).

  • Logout Route (/logout)

  • Ends the session by destroying the user's session data and redirecting them to the homepage.

  • Session Handling (passport.serializeUser & passport.deserializeUser)

  • Saves the user's ID in the session after login.

  • Retrieves the user's data from the database whenever needed.

There are no direct POST requests since user authentication is handled by external providers (Google & GitHub) through Passport.js.

# GET & POST Requests in clubRoutes.js

Method Route Access Description
GET /create Admin only Displays the form to create a new club.
POST /create Admin only Processes club creation.
GET /:clubId/dashboard Club Admin Loads the club's dashboard.
GET /:clubId/edit Club Admin Displays the edit form for the club.
POST /:clubId/edit Club Admin Updates club details.
GET /:clubId/assign-admin Club Admin Shows the form to assign a new club admin.
POST /:clubId/assign-admin Club Admin Assigns a new admin to the club.

# Public Routes (Accessible Without Login) These routes do not require authentication, allowing any user to view club information.

Method Route Access Description
GET / Public Retrieves a list of all clubs.
GET /:clubId Public Fetches details of a specific club.

# Key Takeaways

  • Protected routes require authentication (isAuthenticated) and role validation (isAdmin or isClubAdmin).
  • Admins can create clubs and assign admins, while club admins can edit and manage their clubs.
  • Public routes allow users to view club details without logging in.
  • Follows MVC structure by using clubController to handle business logic.

# The profile.js file handles profile management, including updating user details, viewing profiles, and deleting accounts. These routes are protected, meaning users must be logged in (isAuthenticated) to access them.

# POST Requests in profile.js Protected Routes (Require Authentication) These routes ensure that only logged-in users can access or modify their profile information.

Method Route Description
GET /update-profile Displays the form for updating the user's profile.
POST /update-profile Processes the profile update after validation.
GET /profile Shows the logged-in user's profile details.
GET /delete-account Renders the account deletion confirmation page.
POST /delete-account Permanently deletes the user's account.

# Key Takeaways

  • All routes require authentication (isAuthenticated).
  • Profile updates go through validation (validateProfileInput).
  • Users can update, view, and delete their accounts securely.
  • Follows MVC structure by delegating logic to profileController.

Clone this wiki locally