Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/firebase auth #53

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Feature/firebase auth #53

wants to merge 6 commits into from

Conversation

r800360
Copy link
Member

@r800360 r800360 commented Jan 29, 2025

Tracking Info

Resolves #2 , #9 , #35

Changes

First Issue (#2):
Set Up Firebase for User Sign/Up Flow
-- Create Backend Create User Route (Following onboarding repo conventions)
-- Backend Routes handle Firebase portions
-- Store the UID that Firebase returns to pass to MongoDB
-- Simple dummy Sign up pages to test (Put it under Frontend/src/app/pages)

Second Issue (#9):
-- Set up the frontend request to send to Firebase to login user.

Third Issue (#35):

-- API call to the backend to fetch user identity - Get the user Identity from the backend by grabbing user data from the database
-- For login, create route to authenticate the user where Backend verifies Firebase token
-- Log user out

You can use the Sign up page and Log In pages that I created to test this pull request.

Confirmation of Change

To see the change, try signing up a user and logging that user in. Then, log the user out. I may add in a master page to better test the fetching of user identity if needed.

Message me on Slack for .env files for the frontend and backend.

@r800360 r800360 requested a review from Miyuki-L as a code owner January 29, 2025 23:11
@Miyuki-L Miyuki-L requested a review from andrewzpu January 29, 2025 23:42
Copy link
Member

@Miyuki-L Miyuki-L left a comment

Choose a reason for hiding this comment

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

Greate work on the firebase stuff its a large task and lots of work

There is a lot of extra code that isn't called that I'm not sure we need nor certain about its purpose some i don't even think have its matching backend or is needed

Please address the comments or responde to them if any questions

Copy link
Member

Choose a reason for hiding this comment

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

do we need this?

What additional git ignores does this do ontop of the ones already existing in the .gitignore file at the root of the repository

Copy link
Member

Choose a reason for hiding this comment

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

package.json and package-lock.json shouldn't be needed in the root folder. Delete these two files

Copy link
Member

Choose a reason for hiding this comment

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

we are using the app directory format of next js so app/login/page.tsx would result in the route /login rendering the file page.tsx. so rename and move the page to a folder called login

Copy link
Member

Choose a reason for hiding this comment

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

Same comment can we try to use reacthook form

if not create a type for the form and then use it as the useState

type LoginForm {
email:string;
}
...
useState

Something like that see the example given on the signup file comment


export const verifyUser = async (firebaseToken: string): Promise<APIResult<User>> => {
try {
const response = await GET("/user", createAuthHeader(firebaseToken));
Copy link
Member

Choose a reason for hiding this comment

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

was this suposed to be the "/whoami" route?

Authorization: `Bearer ${firebaseToken}`,
});

export const verifyUser = async (firebaseToken: string): Promise<APIResult<User>> => {
Copy link
Member

Choose a reason for hiding this comment

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

Don't think you are calling this function let's call it on the login page after submitting the loging and getting the togen back from the usercredentials See pap's onSubmit for the login page https://github.com/TritonSE/PAP-Inventory-Processing/blob/ea2e7275d40f10fca354eb749f253a52cc75ef60/frontend/src/app/login/page.tsx#L85

email: string;
profilePicture: string;
lastChangedPassword: Date;
archived: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

whats the meaning and purpose of the last two?

}
};

export async function getNotApprovedUsers(firebaseToken: string): Promise<APIResult<User[]>> {
Copy link
Member

Choose a reason for hiding this comment

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

What is this purpose?

Don't think the route this thing calls is even defined?

}
}

export async function approveUser(email: string, firebaseToken: string): Promise<APIResult<void>> {
Copy link
Member

Choose a reason for hiding this comment

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

same here and below purpose of approve and deny users?

): Promise<APIResult<void>> {
try {
const headers = createAuthHeader(firebaseToken);
const response = await DELETE(`/user/delete/${encodeURIComponent(email)}`, undefined, headers);
Copy link
Member

Choose a reason for hiding this comment

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

Don't think this route is defined? even for the backend route that are commented out it doesn't match

}
}

type ObjectId = string; // This is a placeholder for the actual ObjectId type
Copy link
Member

Choose a reason for hiding this comment

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

Are all the functions below requests to our backend?

for the photos the plane is to store in firebase and store only in our db a url to the photo. Not sure the purpose of the below functions if being sent to our db

Copy link
Member

Choose a reason for hiding this comment

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

Not sure about the purpose and use of most of these functions

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.

Authentication Firebase Set Up
2 participants