Skip to content

feat: restrict login to student accounts by validating "STUDENT_PHOTO… - #6

Merged
sach-12 merged 4 commits into
pesu-dev:mainfrom
jois-code:jois-code/restrict-student-accounts
Oct 12, 2026
Merged

sach-12 merged 4 commits into
pesu-dev:mainfrom
jois-code:jois-code/restrict-student-accounts

Conversation

@jois-code

@jois-code jois-code commented Oct 6, 2026 •

Copy link
Copy Markdown
Member

Description

Restricts OAuth authentication strictly to valid student accounts by verifying the presence of official student metadata (nameAsInSSLC) in the Academy dispatcher response.

Previously, if a non-student account authenticated at /mobilelogin/auth, the dispatcher lookup for student records returned no record, but the system swallowed this and returned null. This allowed non-students to log in with empty academic fields (Program: N/A, Branch: N/A, Semester: -).

With this change:

  • fetchProfileDetails validates that data.MESSAGE contains 'SUCCESS', STUDENT_PHOTO is present, and nameAsInSSLC is a non-empty string.
  • If these conditions are not met, an AcademyAuthError('Only student accounts are supported') is thrown, halting login with HTTP 400.
  • Unit tests have been updated and extended to cover rejection scenarios for missing student records and missing SSLC names.

Fixes #5


Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Tests
  • CI/CD
  • Refactor
  • Security

Testing

  • Unit tests (pnpm test)
  • TypeScript typecheck (pnpm typecheck)
  • Production build (pnpm build)
  • Manual local run (pnpm dev)
  • CI green
  • Docker build (PR workflow)

Checklist

  • Targets main
  • Follows CONTRIBUTING.md
  • No secrets or credentials committed
  • Docs updated if behavior or setup changed
  • ESLint clean (pnpm lint)

Copilot AI balanced review requested due to automatic review settings October 6, 2026 16:03
@jois-code
jois-code requested a review from a team as a code owner October 6, 2026 16:03

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Incomplete session metadata can bypass student verification, and whitespace-only SSLC names lack test coverage.

Review effort: Lite
Findings: 1 High severity

Open (1)

Comment thread src/lib/academy/client.ts

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

The new mandatory userId check conflicts with nullable session flows and should be relaxed.

Review effort: Lite
Findings: None

Resolved since last review (1)

@jois-code

Copy link
Copy Markdown
Member Author

@sach-12 LGTM merge after review

Comment thread tests/unit/lib/academy/client.test.ts
Comment thread tests/unit/lib/academy/client.test.ts
@jois-code
jois-code requested review from achyu-dev and a lite review from Copilot October 8, 2026 03:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No blocking issues remain; only a minor naming nit was identified.

0 open findings

🧠 Review effort: Lite


Give feedback about Copilot approvals in this survey to enter a drawing for a $150 gift card.

@sach-12
sach-12 added this pull request to the merge queue Oct 12, 2026
Merged via the queue into pesu-dev:main with commit 4559b32 Oct 12, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactoring variables and adding auth wall by restricting non students from accessing the oAuth page

4 participants