Skip to content

Fix#3 : Implement Firebase authentication with domain validation#47

Open
ShirshenduR wants to merge 11 commits intobsoc-bitbyte:mainfrom
ShirshenduR:Fix#3auth
Open

Fix#3 : Implement Firebase authentication with domain validation#47
ShirshenduR wants to merge 11 commits intobsoc-bitbyte:mainfrom
ShirshenduR:Fix#3auth

Conversation

@ShirshenduR
Copy link
Copy Markdown

Overview

  1. This PR fixes or fixes part of [Feature Request] [Backend]: Integrate Google Login with Organization Domain Restriction #3
  2. This PR does the following:
    In this PR I have added firebase auth for and login for both via registering and also by google sign in. Add the Exam-bud-firebase.json from Firebase console and setup both frontend and backend envs. Btw I have not made protected route right now

Essential Checklist

  • The PR title starts with "Fix #bugnum: ", followed by a short, clear summary of the changes. (If this PR fixes part of an issue, prefix the title with "Fix part of #bugnum: ...".)
  • "Allow edits from maintainers" is checked. (See here for instructions on how to enable it.)
  • The PR is made from a branch that's not called "main/master".

Proof that changes are correct

Screen.Recording.2025-07-25.at.5.01.32.AM.mov

PR Pointers

  • If you need a review or an answer to a question, and don't have permissions to assign people, leave a comment like the following: "{{Question/comment}} @{{reviewer_username}} PTAL".
  • Never force push. If you do, your PR will be closed.

@ShirshenduR
Copy link
Copy Markdown
Author

@ritankarsaha please review actually last pr got some issue so I made new and closed it

@ritankarsaha
Copy link
Copy Markdown
Collaborator

Sure @ShirshenduR , will review and let you know

@ritankarsaha
Copy link
Copy Markdown
Collaborator

don't worrt abt the linting fail, it's alright

@ShirshenduR
Copy link
Copy Markdown
Author

ShirshenduR commented Jul 26, 2025

@ritankarsaha @harshiill are there any issues, is this pr good?

Comment thread backend/.env.test
Comment on lines -1 to -12


# DATABASE_URL="postgresql://johndoe:randompassword@localhost:5432/mydb?schema=public"

# DATABASE_URL="postgresql://prisma:prisma@db:5432/exam_bud?schema=public"
DATABASE_URL="postgresql://prisma:prisma@db:5432/exam_bud_test?schema=public"
NODE_ENV=test

PORT=4000

CLOUDINARY_URL=cloudinary://<your_api_key>:<your_api_secret>@<product_environment_name>
CLOUDINARY_PUBLIC_ID=<product_environment_name> No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why is this file deleted ? @ShirshenduR

Comment on lines -1 to -7
module.exports = (req, res, next) => {
req.user = {
id: parseInt(req.header('x-user-id')) || 1,
role: req.header('x-user-role') || 'USER',
};
next();
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

don't delete middlewares, create a separate file to add the same and remove dummy features

Comment on lines +52 to +54
router.get('/me', require('../middleware/FirebaseAuth.js'), (req, res) => {
res.json({ success: true, user: req.user });
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

what is this /me route doing @ShirshenduR ?

Comment on lines +56 to +60
router.post('/verify-domain', (req, res) => {
const { email } = req.body;
const isValidDomain = email?.endsWith('@iiitdmj.ac.in');
res.json({ success: true, isValidDomain });
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

why do we need to verify the domain exactly? @ShirshenduR

Comment on lines +7 to +10
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
projectId: process.env.FIREBASE_PROJECT_ID
});
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

provide proper env sample for the same in thje pr description @ShirshenduR

Comment on lines +227 to +233
}

.user-avatar {
width: 40px;
height: 40px;
border-radius: 50%;
object-fit: cover;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

3 participants