Skip to content

Google oauth starter #5

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

Merged
merged 13 commits into from
Jun 27, 2025
Merged

Google oauth starter #5

merged 13 commits into from
Jun 27, 2025

Conversation

joseph-akintunde
Copy link
Contributor

This pull request is displaying the different authentications I have implemented using firebase. I changed the formats for my auth functions for sign up, sign in with and google to one i'm similar and also fetched from the functions http (http://127.0.0.1:5001/feedplanner/us-central1/validateUserJWTToken). This verifies using the Authorization - Bearer HTTP authorization that the token belongs to a particular. Also, the user's details display in my firestore database after verification takes place. Next goals include creating collections for my pantry and mealplanner in the db, completing my MVP and making the UI look great

MILESTONE:
Milestone 1 was getting the welcome page, auth page and home page situated so this is a step in the right direction.

RESOURCES:
I learned to verify JWTs from a part of this tutorial: https://youtu.be/_fv4e8LgMqg?si=WsXJRUcSQJDrRn-y

TEST PLAN:

Screen.Recording.2025-06-27.at.11.19.08.AM.mov

it doesnt allow files bigger than 10mb to paste

Comment on lines 13 to 15
if(!authorizationHeader || !authorizationHeader.startsWith('Bearer ')){
return res.status(401).json({error: "Unauthorized"})
}

Choose a reason for hiding this comment

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

What is 'Bearer '? Why do we need this check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a bearer is needed in the authorization header to hold the token for the user credentials. the block of code is not needed. I was mainly using it to check the functionality of the url on insomnia. say i go to insomnia and i key in anything not Authorization as the key and anything not "Bearer " as the value, it just returns an error.

const nav = useNavigate()
function isSignedOut(){
signOut(auth).then(() => {
console.log("Signed out Successfully")

Choose a reason for hiding this comment

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

Remove console log statements

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

return(
<div>
<header>
<img src="img/logo.png" alt="" />

Choose a reason for hiding this comment

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

Always add alt text

<header>
<img src="img/logo.png" alt="" />
<nav>
<p>Welcome {email ? email : ''}</p>

Choose a reason for hiding this comment

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

If the email is empty, that means some error as occured right? Displaying an empty string '' might be confusing, can we throw an error if that is the case?

Feel free to do it as a follow up if this is hard to implement right now

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah i don't think i can throw an error in a ternary. maybe there's some other way i can go about it.

const googleUser = googleUserCred.user
const token = await googleUser.getIdToken(true)
const response = await fetch(
"http://127.0.0.1:5001/feedplanner/us-central1/validateUserJWTToken",

Choose a reason for hiding this comment

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

Can we const this string somewhere in the project instead of hard coding here?

Maybe we can have a dedicated file for Urls in the project

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i stored it as the base url in the env and imported it.

console.log(user)
const token = await user.getIdToken(true)
const response = await fetch(
"http://127.0.0.1:5001/feedplanner/us-central1/validateUserJWTToken",

Choose a reason for hiding this comment

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

DItto

//getting the access token
const token = await user.getIdToken(true)
const response = await fetch(
"http://127.0.0.1:5001/feedplanner/us-central1/validateUserJWTToken",

Choose a reason for hiding this comment

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

Ditto

@jay24rajput
Copy link

jay24rajput commented Jun 27, 2025

image

Why do we usee the email and password field twice? Shouldn't sign up and login be seperate pages?

@joseph-akintunde
Copy link
Contributor Author

this is not close to the final design but i want to have both on the same page but toggled so when one is clicked the other doesn't show

Copy link

@jay24rajput jay24rajput left a comment

Choose a reason for hiding this comment

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

One nit comment, overall looks good!

export function ErrorPage(){
return(
<div>
<h1>404 NOT FOUNDDDDD</h1>

Choose a reason for hiding this comment

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

nit: FOUND

@joseph-akintunde joseph-akintunde merged commit bb37fc1 into main Jun 27, 2025
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.

2 participants