fix: make Google auth flow reliable and success-gated
Issue Description Google authentication is failing inconsistently in the frontend flow. In failure scenarios (invalid Firebase setup, missing Google access token, or non-JSON backend response), the app may still proceed in UI flow, leading to confusing behavior and failed login state.
Expected behavior
- Google login/register should proceed only when auth succeeds.
- Navigation should happen only after successful backend token exchange.
- Failures should show clear feedback and keep user on current auth page.
- Missing Firebase config should fail gracefully, not break flow.
Actual behavior
- Auth helpers did not consistently guard config/token/parsing failures.
- Login/Register handlers could navigate even when Google auth failed.
- Backend response parsing could throw when response was not JSON.
Proposed fix
- Add safe JSON parsing in auth flow.
- Guard Firebase auth initialization before popup flow.
- Safely extract Google token from Firebase credential.
- Make Google auth helpers return explicit success/failure.
- Navigate only when success is true.
PR Summary This PR hardens Google auth flow so it is success-gated and failure-safe.
What changed
AuthContext:- Added safe localStorage JSON parsing.
- Added safe response JSON parser.
- Added Firebase config/auth guard before popup.
- Added robust Google token extraction.
- Updated
SignInWithGoogle/SignUpWithGoogleto return boolean success.
Login/Register:- Navigate only when Google auth helper returns success.
Result
- No false-success redirects.
- Better error handling for misconfiguration/backend failures.
- More reliable Google login/register UX.
Summary by CodeRabbit
- Bug Fixes
- Improved Google sign-in and sign-up error handling with user-friendly alerts instead of silent failures
- Fixed authentication flow to navigate to dashboard only on successful login or to profile on successful registration
- Enhanced token extraction reliability and validation for Google OAuth authentication
[!WARNING]
Rate limit exceeded
@VarshiniGuntihas exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 10 seconds before requesting another review.β How to resolve this issue?
After the wait time has elapsed, a review can be triggered using the
@coderabbitai reviewcommand as a PR comment. Alternatively, push new commits to this PR.We recommend that you space out your commits to avoid hitting the rate limit.
π¦ How do rate limits work?
CodeRabbit enforces hourly rate limits for each developer per organization.
Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.
Please see our FAQ for further information.
βΉοΈ Review info
βοΈ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID:
dc2f1aef-00cb-400b-8d65-0827a01d21ebπ₯ Commits
Reviewing files that changed from the base of the PR and between da02c49c853b4ccbe73cfb33a9a06cc874dc12c4 and 9a418d623be0d4114b299cec4120080a4a3eff19.
π Files selected for processing (1)
app/src/Context/AuthContext.jsx
Walkthrough
Authentication error handling is improved across three components. AuthContext now provides robust Google OAuth token extraction with fallback logic, user-facing alerts for errors, and boolean return values to indicate success or failure. Login and Register components conditionally navigate based on authentication outcomes rather than unconditionally.
Changes
| Cohort / File(s) | Summary |
|---|---|
OAuth Error Handling & Token Management app/src/Context/AuthContext.jsx |
Firebase config errors now show user alerts; Google OAuth token extraction uses GoogleAuthProvider.credentialFromResult with fallback to response.user.accessToken; backend calls send computed accessToken; functions return boolean values; error handling logs to console and shows alerts; cancellations explicitly return false. |
Conditional Navigation app/src/components/Login.jsx, app/src/components/Register.jsx |
Navigation to home/profile routes now depends on authentication success flags instead of executing unconditionally; sign-in/registration results are checked before routing. |
Estimated code review effort
π― 3 (Moderate) | β±οΈ ~25 minutes
Poem
π° With tokens secured and errors made clear, Our OAuth flows now have no fear, Navigation waits for success to align, No more blind hopsβjust a cleaner design! β¨
π₯ Pre-merge checks | β 2 | β 1
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
β Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | β Passed | The title accurately summarizes the main change: making Google auth flow reliable and success-gated, which aligns with the changeset's core objective. |
| Description check | β Passed | The description is comprehensive, covering issue context, expected/actual behavior, proposed fixes, and implementation details. However, the Type of Change checkboxes and some template sections are not filled out. |
βοΈ Tip: You can configure your own custom pre-merge checks in the settings.
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
π Coding Plan
- [ ] Generate coding plan for human review comments
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
[!TIP]
You can make CodeRabbit's review stricter and more nitpicky using the `assertive` profile, if that's what you prefer.
Change the
reviews.profilesetting toassertiveto make CodeRabbit's nitpick more issues in your PRs.
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (605)
actionlist
addfriend
addlink
aditya
adn
aec
alignof
amazonaws
amqp
antialiased
apexcharts
api
apk
APPS
args
argv
Arial
arrowright
asc
asgi
asm
atcoder
atcoderuser
atlaskit
atn
attr
atv
authtoken
autocomplete
autodiscover
axios
AZERBAIJANI
backend
barcode
bbb
bdsw
bebec
bitbucket
bitcoin
bitset
Bitstream
blang
blinenums
blockquote
blog
bradlc
breadcrumb
bsd
btc
btn
calendarbox
calendarin
calendarlink
calendarnav
Cantarell
ccc
CCPS
CCPSAPI
ccpsleetcoderanking
ccshowfriends
cdata
cdn
changelink
changelist
charset
checkbox
checkboxes
chmod
chooseall
cjs
classmethod
clearall
clickjacking
clockbox
clocklink
clojure
closelink
cls
clsx
cmdk
cnt
cny
codechef
codecheffriends
codeforces
codeforcesfriends
codeforcesuser
collectstatic
colspan
combobox
concat
config
Consolas
constexpr
contenttypes
coreapi
coredocs
cors
corsheaders
cpp
CRA
cred
crontab
csh
csrf
csrftoken
css
ctz
curated
curleft
curtop
cva
cxx
dabapps
dadce
dafb
darkmode
dartdoc
datetime
datetimeshortcuts
davegandy
dbaeumer
dblclick
dce
ddd
decltype
dedent
deletelink
deno
deps
describedby
dest
dfd
dirname
DIRS
discription
discussionpost
disscussion
django
djangoproject
Dmitriy
dnd
dnt
dockerfile
doctype
dotenv
downcode
Downcoder
draggable
drf
dribbble
DRILLDOWN
Droid
dropbox
dropdown
dropfriend
droppable
eaed
ececf
edecd
eee
efb
efcajlnqvdqjeoud
ele
elems
elif
elsif
enctype
endif
entrypoint
enum
EOL
eot
errexit
errorlist
errornote
esac
esbenp
eslint
eur
facebook
favicon
fbfbfc
FCalcutta
fdd
Fefer
fetchall
ffc
ffefef
fff
fieldset
fieldsetcollapser
filteredusers
findpos
Fira
flatpage
flickr
fontawesome
fontawesomeregular
foreach
formset
fromtimestamp
frontend
func
gamepad
gbp
getccfriends
getcffriends
getenv
getghfriends
getltfriends
gettext
ghshowfriends
github
githubfriends
githubusercontent
gittip
globals
glyphicons
gmail
gohri
google
GOOGLEDATA
gotop
graphql
grayscale
GSo
gtcvau
halflingsregular
hdd
heatmap
hexcolor
hiddenfields
hljs
Holovaty
hookform
horiz
howto
href
hsl
htm
html
http
Hyperlinked
ical
icnt
ico
iefix
ifdef
ifndef
iframe
img
inbox
INITDB
inlinechangelink
inlines
inlineviewlink
inp
inr
insertapi
Insitute
instagram
instanceof
INTV
isoformat
isready
Jannis
javadoc
javascript
javascriptreact
jpg
jpy
jsguide
json
jsx
jti
jumbotron
jumotron
JWK
jwt
keydown
keyframes
keyup
krw
kwargs
kwd
kwv
lbh
lccal
Lconf
leaderboard
leaderboardpro
leetcode
leetcodecontestrankings
leetcodefriends
leetcoderanking
leetcoderankingsccps
Leetocde
Leidel
len
Lexer
lify
lightgrey
linecap
linejoin
linenums
linkedin
linting
linux
linuxhint
localhost
lockfile
lodash
loglevel
logresponse
lsaquo
LTshowfriends
lucide
madueke
majodev
makemigrations
maxcdn
maxlength
medkit
meh
Memon
messagelist
metadata
Microsoft
middleware
mixin
mjs
mongodb
moz
mozilla
mql
multiline
mxml
namearr
namespace
navbar
ndx
Neue
ngettext
nginx
nocode
nodejs
nodesource
nonday
noopener
noreferrer
normarr
noscript
nowrap
npm
npx
nullptr
nums
offcanvas
ofhiuvw
OFL
oklch
onrender
openlake
opensource
opentype
opn
orderby
osx
outdent
pagelines
paginator
params
pathlib
perl
pgettext
Phalip
php
phpdoc
pinterest
pln
plugin
png
pnpm
Polovnyov
Polyfill
popup
postgre
postgresql
Powershell
PPK
pragma
prepopulate
prepopulated
prettyprint
progid
pyguide
pylint
pymongo
pypi
PYTHONPATH
qrcode
queryset
Quicklink
quirksmode
qyu
rabbitmq
radiolist
reactjs
readonly
redis
redislabs
regex
regexp
regresponse
reinit
renren
replypost
resizable
retweet
rgba
rmb
rmq
Roboto
robotstxt
rohit
rpdttenqphkdyvpuoeky
rsaquo
rsc
rss
rstrip
rtl
runserver
sbyte
scrollbars
scss
sdk
searchbar
searchfield
Segoe
selectfilter
selectfilterstacked
serializer
setattr
setcontestoptions
setdefault
setis
shadcn
showall
simplejwt
sitemap
sizeof
skype
solvedc
solvedl
sortoptions
sortpriority
sortremove
spsiphnqk
sqlite
src
stackalloc
stan
standalone
startproject
staticfiles
stderr
stdout
strftime
strictfp
strikethrough
stringify
strptime
stswe
styleguide
subdir
substr
sudo
Sumagna
sumagnadas
supabase
svg
svgr
svh
Swicegood
sys
tabbable
tabstyle
tailwindcss
tanstack
tbody
textarea
textfield
tfoot
thead
timedelta
timelist
timezone
timezonewarning
todisplayusers
TODO
toolbar
tooltag
tooltip
toplinks
trello
tripathi
truetype
tsx
ttext
ttf
TTFB
ttg
tumblr
typedef
typeid
typename
typeof
uage
ubuntu
uid
uint
ulk
ulong
uname
undef
unicode
unmounts
unsubscribe
upvotes
uri
url
URLCONF
urlencode
urlencoded
urlify
urllib
urlpatterns
usd
username
userphoto
userpic
usertasks
ushort
usr
utc
utf
utils
UUID
UXux
validator
venv
vercel
verdana
vhdl
VHOST
viewlink
viewsets
viewsitelink
vimeo
visualise
vitejs
vitest
vmin
vnd
vscode
vue
wantarray
webfont
webkit
webpack
website
weibo
whiteants
whitenoise
wiki
winutils
woff
WORKDIR
wsgi
www
xae
xaxis
xcode
XFrame
xfull
xhr
XHT
xhtml
XIcon
xing
xlink
xml
xmlns
xmp
XReg
xsl
xss
yaml
yapf
yaxis
youmightnotneedjquery
youtube
yuaoh
yzo
Some files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
(?:^|/)__init__\.py$
(?:^|/)codechef\.svg$
(?:^|/)github\.svg$
(?:^|/)leetcode\.svg$
(?:^|/)pnpm-lock\.yaml$
[^/]\.eot$
[^/]\.ttf$
[^/]\.woff$
^\Q.cspell.json\E$
^\Qapi/staticfiles_build/static/rest_framework/docs/js/highlight.pack.js\E$
^\Qapi/staticfiles_build/static/rest_framework/js/coreapi-0.1.1.js\E$
^api/leaderboard/contest_data\.json$
^api/requirements\.txt$
^api/staticfiles_build/static/admin/img/gis/
^api/staticfiles_build/static/rest_framework/fonts/glyphicons-halflings-regular\.woff2$
^app/dump\.rdb$
^app/src/logo\.svg$
You should consider excluding directory paths (e.g. (?:^|/)vendor/), filenames (e.g. (?:^|/)yarn\.lock$), or file extensions (e.g. \.gz$)
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct and update file exclusions, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the fix/google-auth-login-flow branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/22404651818/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words not in the :blue_book: dictionary
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 62 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:html/dict/html.txt | 2060 | 46 | 7 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:html/dict/html.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (4)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: binary-file | 15 |
| :warning: minified-file | 1 |
| :warning: noisy-file | 5 |
| :warning: single-line-file | 10 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (26)
amaydixit
arpit
atcoder
atcoderuser
ctz
efcajlnqvdqjeoud
FCalcutta
fns
FOSSOVERFLOW
grindset
gtcvau
Hacktoberfest
heatmap
ical
idx
iframe
kenkoooo
lccal
linecap
linejoin
lstrip
Maxed
noopener
spsiphnqk
startswith
ulk
These words are not needed and should be removed
CRA leetcoderankingccps signupSome files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
^\Q.cspell.json\E$
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the fix/google-auth-login-flow branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23126581429/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 63 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:html/dict/html.txt | 2060 | 46 | 7 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:html/dict/html.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: noisy-file | 1 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).
@check-spelling-bot Report
:red_circle: Please review
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
Unrecognized words (26)
amaydixit
arpit
atcoder
atcoderuser
ctz
efcajlnqvdqjeoud
FCalcutta
fns
FOSSOVERFLOW
grindset
gtcvau
Hacktoberfest
heatmap
ical
idx
iframe
kenkoooo
lccal
linecap
linejoin
lstrip
Maxed
noopener
spsiphnqk
startswith
ulk
These words are not needed and should be removed
CRA leetcoderankingccpsSome files were automatically ignored :see_no_evil:
These sample patterns would exclude them:
^\Q.cspell.json\E$
You should consider adding them to:
.github/actions/spelling/excludes.txt
File matching is via Perl regular expressions.
To check these files, more of their words need to be in the dictionary than not. You can use patterns.txt to exclude portions, add items to the dictionary (e.g. by adding them to allow.txt), or fix typos.
To accept these unrecognized words as correct, update file exclusions, and remove the previously acknowledged and now absent words, you could run the following commands
... in a clone of the [email protected]:VarshiniGunti/Leaderboard-Pro.git repository
on the fix/google-auth-login-flow branch (:information_source: how do I use this?):
curl -s -S -L 'https://raw.githubusercontent.com/check-spelling/check-spelling/main/apply.pl' |
perl - 'https://github.com/OpenLake/Leaderboard-Pro/actions/runs/23126866054/attempts/1' &&
git commit -m 'Update check-spelling metadata'
Available :books: dictionaries could cover words (expected and unrecognized) not in the :blue_book: dictionary
This includes both expected items (592) from .github/actions/spelling/expect.txt and unrecognized words (26)
| Dictionary | Entries | Covers | Uniquely |
|---|---|---|---|
| cspell:django/dict/django.txt | 393 | 63 | 18 |
| cspell:software-terms/dict/softwareTerms.txt | 1288 | 106 | 15 |
| cspell:python/src/common/extra.txt | 741 | 20 | 13 |
| cspell:npm/dict/npm.txt | 302 | 46 | 10 |
| cspell:fullstack/dict/fullstack.txt | 419 | 42 | 8 |
Consider adding them (in .github/workflows/spelling.yml) in jobs:/spelling::
with:
extra_dictionaries: |
cspell:django/dict/django.txt
cspell:software-terms/dict/softwareTerms.txt
cspell:python/src/common/extra.txt
cspell:npm/dict/npm.txt
cspell:fullstack/dict/fullstack.txt
To stop checking additional dictionaries, add (in .github/workflows/spelling.yml):
check_extra_dictionaries: ""
Warnings :warning: (1)
See the :open_file_folder: files view, the :scroll:action log, or :memo: job summary for details.
| :warning: Warnings | Count |
|---|---|
| :warning: noisy-file | 1 |
See :warning: Event descriptions for more information.
If you see a bunch of garbage
If it relates to a ...
well-formed pattern
See if there's a pattern that would match it.
If not, try writing one and adding it to the patterns.txt file.
Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.
Note that patterns can't match multiline strings.
binary-ish string
Please add a file path to the excludes.txt file instead of just accepting the garbage.
File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.
^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).