@jetthai/cuora 1.0.176 → 1.0.178
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 +22 -0
- package/dist/bundle.mjs +468 -468
- package/package.json +1 -1
- package/src/machine/auth.js +33 -27
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -11,6 +11,7 @@ export default function (request) {
|
|
|
11
11
|
const { clientId, fpToken, sentry, defaultChannel, defaultSubchannel } = request.config
|
|
12
12
|
const tokenKey = `cuora_${clientId}`
|
|
13
13
|
const userKey = `cuora_tempuser`
|
|
14
|
+
const phoneCountryCode = 'phone_countrycode'
|
|
14
15
|
const accountPhoneKey = 'account_phone'
|
|
15
16
|
const accountEmailKey = 'account_email'
|
|
16
17
|
const cookies = new Cookies()
|
|
@@ -31,6 +32,7 @@ export default function (request) {
|
|
|
31
32
|
username: null,
|
|
32
33
|
password: null,
|
|
33
34
|
},
|
|
35
|
+
countryAbbr: null,
|
|
34
36
|
userInfo: {},
|
|
35
37
|
redirectURL: null,
|
|
36
38
|
reCaptchaToken: null,
|
|
@@ -39,23 +41,6 @@ export default function (request) {
|
|
|
39
41
|
idle: {
|
|
40
42
|
entry: 'fetchToken',
|
|
41
43
|
always: [{ target: 'authenticated', cond: 'hasToken' }],
|
|
42
|
-
on: {
|
|
43
|
-
LOGIN_GUEST: {
|
|
44
|
-
target: 'authenticationGuest',
|
|
45
|
-
},
|
|
46
|
-
LOGIN_PHONE: {
|
|
47
|
-
target: 'authentication',
|
|
48
|
-
actions: ['setReCaptchaToken', 'setLoginPhone'],
|
|
49
|
-
},
|
|
50
|
-
LOGIN_EMAIL: {
|
|
51
|
-
target: 'authentication',
|
|
52
|
-
actions: ['setReCaptchaToken', 'setLoginEmail'],
|
|
53
|
-
},
|
|
54
|
-
LOGIN_LOCAL: {
|
|
55
|
-
target: 'authentication',
|
|
56
|
-
actions: 'setLoginLocal',
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
44
|
},
|
|
60
45
|
authentication: {
|
|
61
46
|
invoke: {
|
|
@@ -177,6 +162,21 @@ export default function (request) {
|
|
|
177
162
|
CLEAR: {
|
|
178
163
|
target: '.logout',
|
|
179
164
|
},
|
|
165
|
+
LOGIN_GUEST: {
|
|
166
|
+
target: '.authenticationGuest',
|
|
167
|
+
},
|
|
168
|
+
LOGIN_PHONE: {
|
|
169
|
+
target: '.authentication',
|
|
170
|
+
actions: ['setReCaptchaToken', 'setLoginPhone'],
|
|
171
|
+
},
|
|
172
|
+
LOGIN_EMAIL: {
|
|
173
|
+
target: '.authentication',
|
|
174
|
+
actions: ['setReCaptchaToken', 'setLoginEmail'],
|
|
175
|
+
},
|
|
176
|
+
LOGIN_LOCAL: {
|
|
177
|
+
target: '.authentication',
|
|
178
|
+
actions: 'setLoginLocal',
|
|
179
|
+
},
|
|
180
180
|
LOGIN_3PARTY: {
|
|
181
181
|
actions: 'redirectTo3Party',
|
|
182
182
|
},
|
|
@@ -211,7 +211,7 @@ export default function (request) {
|
|
|
211
211
|
}
|
|
212
212
|
}),
|
|
213
213
|
setLoginPhone: assign((context, event) => {
|
|
214
|
-
const { countryCode, phone, password } = event.data
|
|
214
|
+
const { countryCode, countryAbbr, phone, password } = event.data
|
|
215
215
|
return {
|
|
216
216
|
loginData: {
|
|
217
217
|
provider: 'phone',
|
|
@@ -219,6 +219,7 @@ export default function (request) {
|
|
|
219
219
|
phone,
|
|
220
220
|
password,
|
|
221
221
|
},
|
|
222
|
+
countryAbbr,
|
|
222
223
|
}
|
|
223
224
|
}),
|
|
224
225
|
setLoginEmail: assign((context, event) => {
|
|
@@ -263,12 +264,17 @@ export default function (request) {
|
|
|
263
264
|
setAccount: assign((context, event) => {
|
|
264
265
|
if (context.loginData.phone) {
|
|
265
266
|
cookies.remove(accountEmailKey)
|
|
266
|
-
cookies.set(accountPhoneKey,
|
|
267
|
+
cookies.set(accountPhoneKey, `${context.loginData.phone}`, {
|
|
268
|
+
path: '/',
|
|
269
|
+
maxAge: 60 * 60 * 24 * 7,
|
|
270
|
+
})
|
|
271
|
+
cookies.set(phoneCountryCode, `${context.countryAbbr}_${context.loginData.countryCode}`, {
|
|
267
272
|
path: '/',
|
|
268
273
|
maxAge: 60 * 60 * 24 * 7,
|
|
269
274
|
})
|
|
270
275
|
} else if (context.loginData.email) {
|
|
271
276
|
cookies.remove(accountPhoneKey)
|
|
277
|
+
cookies.remove(phoneCountryCode)
|
|
272
278
|
cookies.set(accountEmailKey, context.loginData.email, {
|
|
273
279
|
path: '/',
|
|
274
280
|
maxAge: 60 * 60 * 24 * 7,
|
|
@@ -308,14 +314,14 @@ export default function (request) {
|
|
|
308
314
|
const redirectURL = urljoin(
|
|
309
315
|
request.config.fullURL,
|
|
310
316
|
'login?' +
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
317
|
+
new URLSearchParams({
|
|
318
|
+
provider,
|
|
319
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
320
|
+
channel: cookies.get('channel') || channel || defaultChannel || 'official',
|
|
321
|
+
subchannel: cookies.get('subchannel') || subchannel || defaultSubchannel || 'pwa',
|
|
322
|
+
// dt,
|
|
323
|
+
platform: 'pwa',
|
|
324
|
+
}).toString()
|
|
319
325
|
)
|
|
320
326
|
window.location.href = redirectURL
|
|
321
327
|
},
|