Conversation
…l plugin and enhanced `useAuth` composable, updating related components, middleware, and the root page redirect logic.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAuthentication state management refactored across components and composables. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
app/pages/(auth)/register.vue (1)
67-70:⚠️ Potential issue | 🟡 Minor
.refine()uses the deprecatedmessageparameter — replace witherror.Zod v4 introduces a single unified
errorparameter for customizing errors, replacingmessage. Themessageparameter is still supported but deprecated. The official Zod v4 docs show.refine()using{ error: "..." }in its params object.♻️ Proposed fix
}).refine(data => data.password === data.confirmPassword, { - message: 'Passwords do not match', + error: 'Passwords do not match', path: ['confirmPassword'] })Based on learnings, in TypeScript files using Zod v4.3.5 or newer, use the
erroroption for both schema-level configuration and validators. Themessageparameter is deprecated.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/pages/`(auth)/register.vue around lines 67 - 70, The Zod refine call that enforces password equality (the .refine(data => data.password === data.confirmPassword, { message: 'Passwords do not match', path: ['confirmPassword'] })) uses the deprecated message option; update the second argument to use the new { error: 'Passwords do not match', path: ['confirmPassword'] } shape so schema-level validation uses the unified error property instead of message (locate the .refine(...) on the registration schema).
🧹 Nitpick comments (2)
app/composables/auth.ts (1)
15-20: Inconsistent reactive-value access betweenisPendinganderror/data.
isPendingdefensively usesunref()to handle bothRef<boolean>and a plainboolean, buterror(line 20) directly accesses.value, implicitly assuming it is always aRef. Ifbetter-authever returnserroras a plain value,session.error.valuesilently yieldsundefined, which the?? nullfallback hides. Apply the sameunrefpattern — or nail down the type — for consistency.♻️ Proposed fix
- const error = computed(() => session.error.value ?? null) + const error = computed(() => unref(session.error) ?? null)🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/composables/auth.ts` around lines 15 - 20, The computed for error is inconsistent with isPending: instead of directly using session.error.value (which assumes a Ref), use unref(session.error) the same way isPending uses unref to handle both Ref and plain values (apply the same to session.data if present); update the computed named error (and any computed accessing session.data) to return unref(session.error) ?? null (and unref(session.data) ?? null) or alternatively enforce the session types so those properties are always Refs—locate the computed declarations named isPending and error in this file to make the change.app/pages/(auth)/register.vue (1)
16-17:isFromSignoutis dead code on the register page.Sign-out always navigates to
/login?signout=true, so a user landing on/registerwill never have?signout=truein the query. This guard can be removed.♻️ Proposed fix
-// Redirect if already logged in (but not if we just signed out - race condition with stale state) -const isFromSignout = computed(() => route.query.signout === 'true') - watch(user, (newUser) => { - // Skip auto-redirect if we just came from sign-out (stale user state may still be present) - if (isFromSignout.value) return - if (newUser) { navigateTo('/library') }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@app/pages/`(auth)/register.vue around lines 16 - 17, The computed isFromSignout (const isFromSignout = computed(() => route.query.signout === 'true')) is dead code on the register page and should be removed; delete the isFromSignout declaration and any references to it in register.vue and simplify the redirect/guard logic (where you check login state) to rely only on the existing isLoggedIn/isAuthenticated check (or equivalent) so the page no longer branches on route.query.signout.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/components/AppHeader.vue`:
- Around line 6-10: handleSignOut currently awaits signOut() and will skip
navigateTo('/login?signout=true') if signOut rejects; wrap the signOut call in
try/catch (or try/finally) inside the handleSignOut function so errors from
signOut are caught, log or surface the error (e.g., console.error or a
user-facing notification) in the catch, and ensure
navigateTo('/login?signout=true') still runs (use finally or call navigateTo in
both success and catch paths) so the user is always redirected after attempting
to sign out.
In `@app/pages/`(auth)/login.vue:
- Around line 28-35: Remove the redundant navigateTo call from the onSubmit
flow: since the watch on user (watch(user, ...) with immediate: true) performs
navigateTo(redirectPath.value) when a new user appears (and skips when
isFromSignout.value is true), delete the explicit navigateTo(redirectPath.value)
inside the onSubmit method (the call at line 83) so only the watcher handles
post-sign-in redirects; leave other onSubmit logic (error handling, signIn
invocation) intact.
In `@app/pages/`(auth)/register.vue:
- Around line 19-26: The watcher on `user` already handles post-registration
navigation to '/library' (see the `watch(user, ...)` block), so remove the
duplicate `navigateTo('/library')` call from the `onSubmit` handler to avoid
double navigation; locate the `onSubmit` function (the form submit handler
around lines 74-99) and delete the `navigateTo('/library')` invocation there,
leaving the watcher-based navigation in place and ensuring any related tests or
comments are updated accordingly.
In `@app/plugins/auth.ts`:
- Around line 3-14: Wrap the async initialization in defineNuxtPlugin in a
try/catch around the authClient.useSession(useFetch) call (inside the plugin
returned by defineNuxtPlugin), so any rejection is caught; on error log it via
the app logger or console and return a safe fallback (e.g., an empty or null
reactive session object) as the provided authSession to avoid crashing app
startup; ensure the plugin still returns the provide object with authSession
whether the call succeeds or fails and reference authClient.useSession, useFetch
and the provided authSession key when applying the change.
---
Outside diff comments:
In `@app/pages/`(auth)/register.vue:
- Around line 67-70: The Zod refine call that enforces password equality (the
.refine(data => data.password === data.confirmPassword, { message: 'Passwords do
not match', path: ['confirmPassword'] })) uses the deprecated message option;
update the second argument to use the new { error: 'Passwords do not match',
path: ['confirmPassword'] } shape so schema-level validation uses the unified
error property instead of message (locate the .refine(...) on the registration
schema).
---
Nitpick comments:
In `@app/composables/auth.ts`:
- Around line 15-20: The computed for error is inconsistent with isPending:
instead of directly using session.error.value (which assumes a Ref), use
unref(session.error) the same way isPending uses unref to handle both Ref and
plain values (apply the same to session.data if present); update the computed
named error (and any computed accessing session.data) to return
unref(session.error) ?? null (and unref(session.data) ?? null) or alternatively
enforce the session types so those properties are always Refs—locate the
computed declarations named isPending and error in this file to make the change.
In `@app/pages/`(auth)/register.vue:
- Around line 16-17: The computed isFromSignout (const isFromSignout =
computed(() => route.query.signout === 'true')) is dead code on the register
page and should be removed; delete the isFromSignout declaration and any
references to it in register.vue and simplify the redirect/guard logic (where
you check login state) to rely only on the existing isLoggedIn/isAuthenticated
check (or equivalent) so the page no longer branches on route.query.signout.
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@app/pages/`(auth)/login.vue:
- Around line 25-35: The watcher currently checks computed isFromSignout (based
on route.query.signout) which remains true for the page lifetime and blocks
later successful sign-ins; change this to a one-shot guard by introducing a
local mutable flag (e.g., consumedSignout or signoutConsumedRef) initialized
from route.query.signout === 'true' (instead of using a computed tied to route)
and inside the watch(user, ...) when you return early because of the signout
flag, set that local flag to false (consume it) so subsequent user changes will
redirect via navigateTo(redirectPath.value); update references from
isFromSignout to the new mutable flag and do not persistently rely on
route.query.signout.
In `@app/plugins/auth.ts`:
- Around line 12-15: The fallback session in app/plugins/auth.ts currently sets
session.error to ref(null), which hides bootstrap initialization failures
exposed by useAuth() and $authSession.error (see app/composables/auth.ts:11-20);
update the fallback to preserve and forward the actual bootstrap error instead
of always null — e.g., accept or capture the bootstrap error used during
initialization and assign session.error = ref(bootstrapError) (or wrap it into
the existing reactive session object) so consumers see the real initialization
error rather than a signed-out state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1006660d-6ff1-4be5-a555-cb8f023ecb27
📒 Files selected for processing (5)
app/components/AppHeader.vueapp/composables/auth.tsapp/pages/(auth)/login.vueapp/pages/(auth)/register.vueapp/plugins/auth.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- app/composables/auth.ts
- app/pages/(auth)/register.vue
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…/libroo into feat/remove-landing-page
Summary by CodeRabbit
Release Notes