feat(auth): add role to auth model, improve user store and align mocks#1
Open
isatian-36 wants to merge 1 commit intomainfrom
Open
feat(auth): add role to auth model, improve user store and align mocks#1isatian-36 wants to merge 1 commit intomainfrom
isatian-36 wants to merge 1 commit intomainfrom
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation
roleused for route/menu filtering.admin/operatorroles so UI/dev flows can reliably exercise role-based behavior.Description
UserRoleand extendedAuthTypewithroleinsrc/api/user/types.tsand preservedrolesonUserInfoTypefor compatibility, enabling typed role handling in the app.roleand continue to persisttoken,refreshTokenandroleviazustand/persistinsrc/store/auth.tsso persisted shape stays stable.src/store/user.tsto addsetUserInfo,hasRoleand keepgetUserInfo/reset, centralizing user state mutations and role checks for UI use.src/router/routes/modules/access.ts(useoperatorinstead ofcommon),fake/auth.fake.ts,fake/user.fake.ts, andfake/async-routes.fake.tsto return/consumeroleconsistently foradmin/operatorscenarios.docs/zh/ecommerce-auth-implementation.mddescribing the login/token/401/dynamic-route flow and notes about using the existingkyrequest layer or swapping toaxioslater.Testing
pnpm typecheck(tsc --noEmit) and the typecheck completed successfully against the modified codebase.eslint --fixon staged files as part of the commit flow and completed (auto-fixes applied to staged files).axiosfor an alternate example (pnpm add axios) but the registry returned403in this environment soaxioswas not added; the repository continues to use the existingkyrequest layer.Codex Task