@jetthai/cuora 1.1.465-dev.3 → 1.1.465-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +1 -1
- package/src/machine/auth.js +21 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [1.1.465-dev.4](https://github.com/jetthai/cuora-module/compare/v1.1.465-dev.3...v1.1.465-dev.4) (2026-08-24)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **auth:** 清除站台已停用登入方式殘留的記住帳號 ([2c6b965](https://github.com/jetthai/cuora-module/commit/2c6b96572108cfc977d7dc99635adebbee01db46))
|
|
11
|
+
|
|
5
12
|
### [1.1.465-dev.3](https://github.com/jetthai/cuora-module/compare/v1.1.465-dev.2...v1.1.465-dev.3) (2026-08-19)
|
|
6
13
|
|
|
7
14
|
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -15,6 +15,13 @@ export default function (request) {
|
|
|
15
15
|
const accountPhoneKey = 'account_phone'
|
|
16
16
|
const accountEmailKey = 'account_email'
|
|
17
17
|
const accountUsernameKey = 'account_username'
|
|
18
|
+
// loginMethods 的鍵 → setAccount 寫入的 storage key。
|
|
19
|
+
// LOGIN_ID 與 LOGIN_LOCAL 都寫 accountUsernameKey,兩者在 loginMethods 都算 'local',此對照無法由 key 名反推。
|
|
20
|
+
const rememberedAccountKeys = [
|
|
21
|
+
['local', accountUsernameKey],
|
|
22
|
+
['phone', accountPhoneKey],
|
|
23
|
+
['email', accountEmailKey],
|
|
24
|
+
]
|
|
18
25
|
|
|
19
26
|
return createMachine(
|
|
20
27
|
{
|
|
@@ -47,7 +54,7 @@ export default function (request) {
|
|
|
47
54
|
src: 'fetchSiteConfig',
|
|
48
55
|
onDone: {
|
|
49
56
|
target: 'idle',
|
|
50
|
-
actions: 'setSiteConfig',
|
|
57
|
+
actions: ['setSiteConfig', 'pruneRememberedAccounts'],
|
|
51
58
|
},
|
|
52
59
|
onError: {
|
|
53
60
|
target: 'idle',
|
|
@@ -341,6 +348,19 @@ export default function (request) {
|
|
|
341
348
|
siteConfig: { ...event.data, loginMethods: pickBy(loginMethods), registerMethods: pickBy(registerMethods) },
|
|
342
349
|
}
|
|
343
350
|
}),
|
|
351
|
+
// setAccount 寫入的帳號 TTL 是 31 天,且只互斥清除另外兩支 key,
|
|
352
|
+
// 後台關掉某種登入方式後殘值仍在,下游會把它回填進已改型別的輸入框(例如把 email 填進 phone-only 站台)。
|
|
353
|
+
// 非 assign action,故取得的是 setSiteConfig 套用後的 context。
|
|
354
|
+
pruneRememberedAccounts: (context) => {
|
|
355
|
+
// fetchSiteConfig 失敗會走 onError 不進到這裡;此處防的是回傳成功但 loginMethods 整包缺失,避免誤清全部記住的帳號。
|
|
356
|
+
const enabledMethods = context.siteConfig?.loginMethods
|
|
357
|
+
if (!enabledMethods || !Object.keys(enabledMethods).length) return
|
|
358
|
+
rememberedAccountKeys.forEach(([method, key]) => {
|
|
359
|
+
if (enabledMethods[method]) return
|
|
360
|
+
storage.remove(key)
|
|
361
|
+
if (method === 'phone') storage.remove(phoneCountryCode)
|
|
362
|
+
})
|
|
363
|
+
},
|
|
344
364
|
setReCaptchaToken: assign((context, event) => {
|
|
345
365
|
const { reCaptchaToken } = event.data
|
|
346
366
|
return {
|