-
Couldn't load subscription status.
- Fork 17
fix: Add missing function type to redirect options #77
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
base: master
Are you sure you want to change the base?
Conversation
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.
|
|
Summary of ChangesHello @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
Using Gemini Code AssistThe 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
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 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
|
WalkthroughThe pull request introduces a new Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🔇 Additional comments (4)
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 |
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||
PR Code Suggestions ✨No code suggestions found for the PR. |
There was a problem hiding this 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.
| authRedirect?: Redirect | ||
| forbiddenRedirect?: Redirect | ||
| notFoundRedirect?: Redirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
User description
Hello, and thank you for your work on this library, especially since @websanova/vue-auth is not maintained anymore
The
authRedirect,forbiddenRedirect, andnotFoundRedirectoptions support callback functions, but the types only allowedRouteLocationRaw.Redirecttype supporting bothRouteLocationRawand(to: RouteLocationNormalized) => RouteLocationRawRedirecttypeThis fixes the type mismatch with the existing implementation in
Auth.ts.PR Type
Bug fix
Description
Add
Redirecttype supporting both static routes and callback functionsUpdate redirect options to accept function-based redirects
Import
RouteLocationNormalizedfrom vue-router for callback typingAlign type definitions with existing implementation
Diagram Walkthrough
File Walkthrough
Options.ts
Add Redirect type and update redirect optionssrc/type/Options.ts
RouteLocationNormalizedfrom vue-router alongside existingimports
Redirecttype union supporting bothRouteLocationRawandcallback function
(to: RouteLocationNormalized) => RouteLocationRawauthRedirect,forbiddenRedirect, andnotFoundRedirectoptionsto use the new
Redirecttype instead ofRouteLocationRawSummary by CodeRabbit