Fix case-sensitivity issues around backend unique identifiers#2964
Fix case-sensitivity issues around backend unique identifiers#2964aofei merged 2 commits intogoplus:devfrom
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
|
Good foundational fix — the distinction between unresolved (JWT-derived) and canonical (API-confirmed) identifiers is clearly articulated in A few things worth addressing before merge:
Inline comments added on the specific locations. |
| }) | ||
| /** Records that the current user has used Copilot when the specified condition is met. */ | ||
| async function recordCopilotUsage(shouldRecord: () => boolean) { | ||
| const signedInState = await untilLoaded(signedInStateQuery) |
There was a problem hiding this comment.
这边原来的逻辑有点乱,还有优化的空间,先不在这次处理了
| <!-- eslint-disable vue/no-v-html --> | ||
| <template> | ||
| <div v-if="!signedInUser" class="sign-in"> | ||
| <div v-if="!loading && signedInUser == null" class="sign-in"> |
There was a problem hiding this comment.
加个 loading 的判断,这样在已登录的情况下,避免在初始化页面时短暂地渲染“登录”按钮
| * - callers only need the signed-in user information | ||
| * - callers don't need to distinguish between "not signed in" and "signed in but user information not available" | ||
| */ | ||
| export function useSignedInUser() { |
There was a problem hiding this comment.
定位跟原 useSignedInUser 类似,不过考虑绝大部分调用方都不关心 queryRet.data 之外的信息,因此在原来的接口基础上把 queryRet 这一层去掉了,直接把 Ref<SignedInUser> 返回
There was a problem hiding this comment.
router.ts 里改了路径参数,这里应该也要跟着改吧?不然修改成功后不会切换到新用户名 url
There was a problem hiding this comment.
嗯是的,这里用的 param 名不对,route.params.* 不是类型安全的,搞不好其他地方也有类似的问题,我再整体过下
另外,这里原有的拿 oldUsername 跟路由参数做比较(然后 return)主要是针对的什么情况?一般来说如果能编辑 profile,应该肯定是在自己的 profile 页面才对
There was a problem hiding this comment.
另外,这里原有的拿
oldUsername跟路由参数做比较(然后 return)主要是针对的什么情况?一般来说如果能编辑 profile,应该肯定是在自己的 profile 页面才对
哦这好像是之前做成修改完用户名后不重定向刷新页面,而是就地替换的时候加的逻辑,现在不需要了,可以干掉
| if (oldUsername == null) throw new Error('Signed-in username is not available') | ||
|
|
||
| const updated = await apis.updateSignedInUser({ username: newUsername }) | ||
| userState.username = updated.username |
There was a problem hiding this comment.
router.ts 的 getOwnProjectEditorRoute 用 getUnresolvedSignedInUsername 来获取 username,如果这里不更新的话,那后续 getOwnProjectEditorRoute 拿到的路由应该都是 old username 拼接的?
There was a problem hiding this comment.
嗯是的这里会有问题,我打算在这里 refresh 下 access token
直接 set userState.username 的话,userState 中的 username 跟其他信息会不一致,也会跟现在 username 的定位(User name parsed from access token)冲突
There was a problem hiding this comment.
我打算在这里 refresh 下 access token
又遇到一个 casdoor 的 bug.. #2990
从代码的排查情况看,即使是改名后正常地 access token 过期触发的 refresh,也会遇到 crash;这么看的话如果我们不去改 casddoor,这边改完 username 得主动登出才能避免这个问题
There was a problem hiding this comment.
5160291 这边我先处理成修改 username 后登出并自动跳转到登录页;Casdoor 那边我尝试提了个 PR 不过还不 ready,总感觉不太放心
…#2964) * Fix case-sensitivity issues around backend unique identifiers * Fix route param names & username update issue
close #2917.