You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The Firestore check in sessionLogin catches errors and returns without sending an HTTP response, which can cause the request to hang. Ensure you send a proper error response before returning.
}catch(error){functions.logger.error("Error when trying to check if user existed for session login",error);return}
There's a second call to auth.getUserByEmail in the sessionLogin else branch even though the user was already fetched earlier, leading to unnecessary overhead. Consider reusing the existing user object.
Both the Firestore write and token generation error handlers in register return a generic "Something went wrong". Differentiating or propagating specific error details could improve debugging.
}catch(error){functions.logger.error("Error when checking existing user for registration:",error);res.status(500).json({status: 500,error: "Something went wrong",});return;}
Sending a response in this catch block prevents the request from hanging when the DB check fails. Include a 500 response and return to properly terminate the request.
} catch (error) {
- functions.logger.error("Error when trying to check if user existed for session login", error);- return+ functions.logger.error("Error when checking user existence for session login", error);+ res.status(500).json({ status: 500, error: "Something went wrong" });+ return;
}
Suggestion importance[1-10]: 8
__
Why: The catch block for checking user existence currently only logs errors and returns, causing requests to hang; adding a 500 response correctly handles failures.
Medium
Security
Harden session cookie settings
For production security, enable secure and set a sameSite policy on your session cookie to mitigate CSRF and ensure it's only sent over HTTPS.
Why: Enabling the secure and sameSite cookie attributes improves session security by ensuring cookies are only sent over HTTPS and mitigating CSRF.
Medium
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
User description
PR Type
Bug fix, Enhancement
Description
Validate name and catch duplicate emails
Skip Firestore write for existing users
Structured error responses in registration flow
Explicit token error handling in login
Changes walkthrough 📝
auth_controller.ts
Refactor auth register and sessionLogin error handlingfunctions/src/controllers/auth_controller.ts