Skip to content

1. Auth Routes

Abdullah bin Ammar edited this page May 20, 2025 · 1 revision

Routes Overview for auth.js

Warning

We're transitioning to University Single Sign-On (SSO),
GitHub and Google authentication are now deprecated and will soon be removed completely.

Method Endpoint Description
GET /auth/google Initiates Google OAuth login.
GET /google/callback Callback after Google login. Redirects user based on first-time login.
GET /auth/github Initiates GitHub OAuth login.
GET /github/callback Callback after GitHub login. Redirects user based on first-time login.
GET /login Renders the login page (login.ejs).
GET /login-failure Displays a failure message if login fails.
GET /logout Logs out the user and destroys the session.
POST (None in this file) OAuth handles login via GET requests.

Key Features

  • Authentication Supports Google & GitHub login using passport.js.
  • User Creation;If a user logs in for the first time, they are in the database.
  • If they log in with a new provider (Google/GitHub), the provider is linked to their existing account.
  • Profile Redirection New users are sent to update-profile for additional setup.
  • Existing users are redirected to profile.
  • Session Handling Uses and to persist user login sessions.
  • Graceful Logout ensures session destruction and user redirection to the homepage.

Authentication

OAuth2 Authentication

Google Authentication

GET /auth/google

Initiates Google OAuth2 authentication flow.

Response:

  • Redirects to Google consent screen

Google Callback

GET /google/callback

Handles Google OAuth2 callback.

Response:

  • Redirects to /update-profile for new users
  • Redirects to /profile for existing users

GitHub Authentication

GET /auth/github

Initiates GitHub OAuth2 authentication flow.

Response:

  • Redirects to GitHub consent screen

GitHub Callback

GET /github/callback

Handles GitHub OAuth2 callback.

Response:

  • Redirects to /update-profile for new users
  • Redirects to /profile for existing users

Session Management

Logout

GET /logout

Destroys the user's session.

Response:

  • Redirects to home page

Clone this wiki locally