@jetthai/cuora 1.0.117 → 1.0.119
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 +4 -0
- package/package.json +1 -1
- package/src/machine/auth.js +24 -9
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
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.0.119](https://github.com/jetthai/cuora-module/compare/v1.0.118...v1.0.119) (2022-05-22)
|
|
6
|
+
|
|
7
|
+
### [1.0.118](https://github.com/jetthai/cuora-module/compare/v1.0.117...v1.0.118) (2022-05-22)
|
|
8
|
+
|
|
5
9
|
### [1.0.117](https://github.com/jetthai/cuora-module/compare/v1.0.116...v1.0.117) (2022-05-18)
|
|
6
10
|
|
|
7
11
|
### [1.0.116](https://github.com/jetthai/cuora-module/compare/v1.0.115...v1.0.116) (2022-05-12)
|
package/package.json
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -10,6 +10,8 @@ export default function (request) {
|
|
|
10
10
|
const { clientId, fpToken, sentry } = request.config
|
|
11
11
|
const tokenKey = `cuora_${clientId}`
|
|
12
12
|
const userKey = `cuora_tempuser`
|
|
13
|
+
const accountKeyPhone = 'account_phone'
|
|
14
|
+
const accountKeyEmail = 'account_email'
|
|
13
15
|
const cookies = new Cookies()
|
|
14
16
|
|
|
15
17
|
return createMachine(
|
|
@@ -58,7 +60,7 @@ export default function (request) {
|
|
|
58
60
|
src: 'authenticate',
|
|
59
61
|
onDone: {
|
|
60
62
|
target: 'authenticated',
|
|
61
|
-
actions: 'setToken',
|
|
63
|
+
actions: ['setToken', 'setAccount'],
|
|
62
64
|
},
|
|
63
65
|
onError: {
|
|
64
66
|
target: 'idle',
|
|
@@ -247,6 +249,19 @@ export default function (request) {
|
|
|
247
249
|
token: event.data,
|
|
248
250
|
}
|
|
249
251
|
}),
|
|
252
|
+
setAccount: assign((context, event) => {
|
|
253
|
+
if (context.loginData.phone) {
|
|
254
|
+
cookies.set(accountKeyPhone, context.loginData.phone, {
|
|
255
|
+
path: '/',
|
|
256
|
+
maxAge: 60 * 60 * 24,
|
|
257
|
+
})
|
|
258
|
+
} else if (context.loginData.email) {
|
|
259
|
+
cookies.set(accountKeyEmail, context.loginData.email, {
|
|
260
|
+
path: '/',
|
|
261
|
+
maxAge: 60 * 60 * 24,
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
}),
|
|
250
265
|
removeToken: assign((context, event) => {
|
|
251
266
|
cookies.remove(tokenKey, {
|
|
252
267
|
path: '/',
|
|
@@ -268,14 +283,14 @@ export default function (request) {
|
|
|
268
283
|
const redirectURL = urljoin(
|
|
269
284
|
request.config.fullURL,
|
|
270
285
|
'login?' +
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
286
|
+
qs.stringify({
|
|
287
|
+
provider,
|
|
288
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
289
|
+
channel: cookies.get('channel') || channel || 'official',
|
|
290
|
+
subchannel: cookies.get('subchannel') || subchannel || 'pwa',
|
|
291
|
+
// dt,
|
|
292
|
+
platform: 'pwa',
|
|
293
|
+
})
|
|
279
294
|
)
|
|
280
295
|
window.location.href = redirectURL
|
|
281
296
|
},
|