Skip to content

Conversation

@adrienWeiss
Copy link

@adrienWeiss adrienWeiss commented Oct 24, 2025

User description

Hello, and thank you for your work on this library, especially since @websanova/vue-auth is not maintained anymore

The authRedirect, forbiddenRedirect, and notFoundRedirect options support callback functions, but the types only allowed RouteLocationRaw.

  • Create Redirect type supporting both RouteLocationRaw and (to: RouteLocationNormalized) => RouteLocationRaw
  • Update redirect options to use the new Redirect type

This fixes the type mismatch with the existing implementation in Auth.ts.


PR Type

Bug fix


Description

  • Add Redirect type supporting both static routes and callback functions

  • Update redirect options to accept function-based redirects

  • Import RouteLocationNormalized from vue-router for callback typing

  • Align type definitions with existing implementation


Diagram Walkthrough

flowchart LR
  A["RouteLocationRaw"] --> C["Redirect type"]
  B["RouteLocationNormalized callback"] --> C
  C --> D["authRedirect option"]
  C --> E["forbiddenRedirect option"]
  C --> F["notFoundRedirect option"]
Loading

File Walkthrough

Relevant files
Bug fix
Options.ts
Add Redirect type and update redirect options                       

src/type/Options.ts

  • Import RouteLocationNormalized from vue-router alongside existing
    imports
  • Create Redirect type union supporting both RouteLocationRaw and
    callback function (to: RouteLocationNormalized) => RouteLocationRaw
  • Update authRedirect, forbiddenRedirect, and notFoundRedirect options
    to use the new Redirect type instead of RouteLocationRaw
+12/-4   

Summary by CodeRabbit

  • Refactor
    • Enhanced redirect configuration to support both static routes and dynamic, function-based redirect logic for authentication, forbidden, and not-found scenarios.

Add proper TypeScript support for callback functions in authRedirect,
forbiddenRedirect, and notFoundRedirect options.

- Import RouteLocationNormalized from vue-router
- Create Redirect type union for static routes and callbacks
- Update redirect options to use the new Redirect type

This aligns type definitions with the existing implementation that
already supports function-based redirects.
@bolt-new-by-stackblitz
Copy link

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@gemini-code-assist
Copy link

Summary of Changes

Hello @adrienWeiss, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the type definitions for redirect options within the library. It ensures that the TypeScript types accurately reflect the runtime behavior where redirect options can be either a static route location or a dynamic function, thereby improving type safety and developer experience when configuring authentication redirects.

Highlights

  • Type Definition for Redirect Options: Introduced a new Redirect type to correctly represent that authRedirect, forbiddenRedirect, and notFoundRedirect options can accept either a RouteLocationRaw or a function that returns a RouteLocationRaw.
  • Improved Type Safety: Updated the Options interface to use the new Redirect type for authRedirect, forbiddenRedirect, and notFoundRedirect, resolving a type mismatch with the existing implementation in Auth.ts.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@coderabbitai
Copy link

coderabbitai bot commented Oct 24, 2025

Walkthrough

The pull request introduces a new Redirect type alias that unions RouteLocationRaw with a function type, and updates three redirect properties (authRedirect, forbiddenRedirect, notFoundRedirect) to use this new type instead of solely RouteLocationRaw. Vue-router type imports are expanded to include RouteLocationNormalized.

Changes

Cohort / File(s) Change Summary
Type definition enhancement
src/type/Options.ts
Added new Redirect type alias combining RouteLocationRaw and a function accepting RouteLocationNormalized to RouteLocationRaw; updated authRedirect, forbiddenRedirect, and notFoundRedirect properties to use Redirect type; expanded vue-router imports to include RouteLocationNormalized

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A redirect route with types so fine,
Functions and locations now align,
Three paths get smarter, logic refined,
Hopping through types, we leave bugs behind!

Pre-merge checks and finishing touches

❌ 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%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The PR title "fix: Add missing function type to redirect options" directly describes the main change in the pull request. According to the PR objectives, the redirect options (authRedirect, forbiddenRedirect, notFoundRedirect) support callback functions at runtime, but their types only allowed RouteLocationRaw. The PR introduces a new Redirect type that includes a function signature and updates these three options to use it, which aligns precisely with the title's description of adding missing function type support. The title is concise, uses clear language without vague terms or noise, and gives a teammate scanning history a clear understanding of the primary change.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9021e6d and ce68564.

📒 Files selected for processing (1)
  • src/type/Options.ts (3 hunks)
🔇 Additional comments (4)
src/type/Options.ts (4)

1-5: LGTM! Import correctly updated.

The addition of RouteLocationNormalized to the imports is necessary for the new Redirect type definition.


14-16: LGTM! Type definition correctly addresses the runtime behavior.

The Redirect type properly captures both static route locations and dynamic redirect functions, aligning the TypeScript types with the existing runtime implementation.


44-46: LGTM! Redirect properties correctly updated.

The three redirect properties now properly accept both static routes and redirect functions, fixing the type mismatch with the runtime implementation.


19-19: The HttpData.redirect property correctly uses only RouteLocationRaw. This difference from the Redirect type is intentional because HttpData.redirect is used in the HTTP request context where route information (RouteLocationNormalized) is unavailable. The three main redirect options (authRedirect, forbiddenRedirect, notFoundRedirect) support function callbacks because they operate in the route guard context where the target route is available to pass to the callback. The implementation correctly reflects this distinction—utility functions like logout(), routerPush(), and setUserData() only accept RouteLocationRaw and don't check for function types.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@qodo-merge-pro
Copy link

PR Compliance Guide 🔍

Below is a summary of compliance checks for this PR:

Security Compliance
🟢
No security concerns identified No security vulnerabilities detected by AI analysis. Human verification advised for critical code.
Ticket Compliance
🎫 No ticket provided
- [ ] Create ticket/issue <!-- /create_ticket --create_ticket=true -->

</details></td></tr>
Codebase Duplication Compliance
Codebase context is not defined

Follow the guide to enable codebase context checks.

Custom Compliance
No custom compliance provided

Follow the guide to enable custom compliance check.

Compliance status legend 🟢 - Fully Compliant
🟡 - Partial Compliant
🔴 - Not Compliant
⚪ - Requires Further Human Verification
🏷️ - Compliance label

@qodo-merge-pro
Copy link

PR Code Suggestions ✨

No code suggestions found for the PR.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

The pull request introduces a new Redirect type to support both static routes and callback functions for authRedirect, forbiddenRedirect, and notFoundRedirect options. This change aligns the type definitions with the existing implementation in Auth.ts, resolving a type mismatch. The code changes look good and address the issue effectively.

Comment on lines +44 to +46
authRedirect?: Redirect
forbiddenRedirect?: Redirect
notFoundRedirect?: Redirect

Choose a reason for hiding this comment

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

medium

The change from RouteLocationRaw to Redirect for the redirect options is correct, but it introduces a potential issue. If a developer expects to only provide a RouteLocationRaw value, they might be surprised that they can also provide a function. It would be beneficial to provide documentation or examples showcasing the usage of the function-based redirect to avoid confusion and ensure proper usage. Consider adding a comment or updating the documentation to reflect this change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant