@jetthai/cuora 1.0.107 → 1.0.108
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 +2 -0
- package/package.json +1 -1
- package/src/api/auth.js +6 -0
- package/src/machine/auth.js +29 -8
- package/src/machine/user_sign_up.js +35 -55
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
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.108](https://github.com/jetthai/cuora-module/compare/v1.0.107...v1.0.108) (2022-04-07)
|
|
6
|
+
|
|
5
7
|
### [1.0.107](https://github.com/jetthai/cuora-module/compare/v1.0.106...v1.0.107) (2022-03-23)
|
|
6
8
|
|
|
7
9
|
### [1.0.106](https://github.com/jetthai/cuora-module/compare/v1.0.105...v1.0.106) (2022-03-22)
|
package/package.json
CHANGED
package/src/api/auth.js
CHANGED
package/src/machine/auth.js
CHANGED
|
@@ -36,6 +36,9 @@ export default function (request) {
|
|
|
36
36
|
entry: 'fetchToken',
|
|
37
37
|
always: [{ target: 'authenticated', cond: 'hasToken' }],
|
|
38
38
|
on: {
|
|
39
|
+
LOGIN_GUEST: {
|
|
40
|
+
target: 'authenticationGuest',
|
|
41
|
+
},
|
|
39
42
|
LOGIN_PHONE: {
|
|
40
43
|
target: 'authentication',
|
|
41
44
|
actions: 'setLoginPhone',
|
|
@@ -66,6 +69,19 @@ export default function (request) {
|
|
|
66
69
|
},
|
|
67
70
|
},
|
|
68
71
|
},
|
|
72
|
+
authenticationGuest: {
|
|
73
|
+
invoke: {
|
|
74
|
+
src: 'authenticateGuest',
|
|
75
|
+
onDone: {
|
|
76
|
+
target: 'authenticated',
|
|
77
|
+
actions: 'setToken',
|
|
78
|
+
},
|
|
79
|
+
onError: {
|
|
80
|
+
target: 'idle',
|
|
81
|
+
actions: 'removeToken',
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
},
|
|
69
85
|
authenticated: {
|
|
70
86
|
invoke: {
|
|
71
87
|
src: 'fetchUserInfo',
|
|
@@ -252,14 +268,14 @@ export default function (request) {
|
|
|
252
268
|
const redirectURL = urljoin(
|
|
253
269
|
request.config.fullURL,
|
|
254
270
|
'login?' +
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
271
|
+
qs.stringify({
|
|
272
|
+
provider,
|
|
273
|
+
redirectURI: `${window.location.protocol}//${window.location.host}`,
|
|
274
|
+
channel: cookies.get('channel') || channel || 'official',
|
|
275
|
+
subchannel: cookies.get('subchannel') || subchannel || 'pwa',
|
|
276
|
+
dt,
|
|
277
|
+
platform: 'pwa',
|
|
278
|
+
})
|
|
263
279
|
)
|
|
264
280
|
window.location.href = redirectURL
|
|
265
281
|
},
|
|
@@ -276,6 +292,11 @@ export default function (request) {
|
|
|
276
292
|
const { token } = await request.send(auth.login(data))
|
|
277
293
|
return token
|
|
278
294
|
},
|
|
295
|
+
authenticateGuest: async (context, event) => {
|
|
296
|
+
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
297
|
+
const { token } = await request.send(auth.guestLogin({ dt }))
|
|
298
|
+
return token
|
|
299
|
+
},
|
|
279
300
|
logout: async (context, event) => {
|
|
280
301
|
return await request.send(auth.logout())
|
|
281
302
|
},
|
|
@@ -11,94 +11,74 @@ export default function (request) {
|
|
|
11
11
|
id: 'user_sign_up',
|
|
12
12
|
initial: 'idle',
|
|
13
13
|
context: {
|
|
14
|
-
|
|
15
|
-
password: '',
|
|
14
|
+
provider: null,
|
|
16
15
|
channel: null,
|
|
17
16
|
subchannel: null,
|
|
17
|
+
signUpData: {},
|
|
18
18
|
},
|
|
19
19
|
states: {
|
|
20
20
|
idle: {
|
|
21
21
|
on: {
|
|
22
|
-
|
|
23
|
-
target: '
|
|
24
|
-
actions: '
|
|
22
|
+
SIGN_UP_PHONE: {
|
|
23
|
+
target: 'authentication',
|
|
24
|
+
actions: 'setSignUpPhone',
|
|
25
25
|
},
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
on: {
|
|
30
|
-
SIGN_UP: {
|
|
31
|
-
target: 'validating',
|
|
32
|
-
actions: 'setForm',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
shortPassword: {
|
|
37
|
-
on: {
|
|
38
|
-
SIGN_UP: {
|
|
39
|
-
target: 'validating',
|
|
40
|
-
actions: 'setForm',
|
|
26
|
+
SIGN_UP_EMAIL: {
|
|
27
|
+
target: 'authentication',
|
|
28
|
+
actions: 'setSignUpEmail',
|
|
41
29
|
},
|
|
42
30
|
},
|
|
43
31
|
},
|
|
44
|
-
|
|
45
|
-
always: [
|
|
46
|
-
{
|
|
47
|
-
target: 'invalidFormat',
|
|
48
|
-
cond: 'isInvalidFormat',
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
target: 'shortPassword',
|
|
52
|
-
cond: 'isLessThan6Characters',
|
|
53
|
-
},
|
|
54
|
-
{
|
|
55
|
-
target: 'submitting',
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
},
|
|
59
|
-
submitting: {
|
|
32
|
+
authentication: {
|
|
60
33
|
invoke: {
|
|
61
|
-
src: '
|
|
34
|
+
src: 'authenticate',
|
|
62
35
|
onDone: {
|
|
63
|
-
target: '
|
|
36
|
+
target: 'authenticated',
|
|
64
37
|
},
|
|
65
38
|
onError: {
|
|
66
39
|
target: 'idle',
|
|
67
40
|
},
|
|
68
41
|
},
|
|
69
42
|
},
|
|
70
|
-
|
|
43
|
+
authenticated: {},
|
|
71
44
|
},
|
|
72
45
|
},
|
|
73
46
|
{
|
|
74
47
|
actions: {
|
|
75
|
-
|
|
48
|
+
setSignUpPhone: assign((context, event) => {
|
|
49
|
+
const { countryCode, phone, password, channel, subchannel } = event.data
|
|
50
|
+
return {
|
|
51
|
+
signUpData: {
|
|
52
|
+
provider: 'phone',
|
|
53
|
+
countryCode,
|
|
54
|
+
phone,
|
|
55
|
+
password
|
|
56
|
+
},
|
|
57
|
+
channel,
|
|
58
|
+
subchannel,
|
|
59
|
+
}
|
|
60
|
+
}),
|
|
61
|
+
setSignUpEmail: assign((context, event) => {
|
|
76
62
|
const { email, password, channel, subchannel } = event.data
|
|
77
63
|
return {
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
signUpData: {
|
|
65
|
+
provider: 'email',
|
|
66
|
+
email,
|
|
67
|
+
password
|
|
68
|
+
},
|
|
80
69
|
channel,
|
|
81
70
|
subchannel,
|
|
82
71
|
}
|
|
83
72
|
}),
|
|
84
73
|
},
|
|
85
|
-
guards: {
|
|
86
|
-
isInvalidFormat: (context, event) => {
|
|
87
|
-
// return !context.email || /[+-]/.test(context.email)
|
|
88
|
-
},
|
|
89
|
-
isLessThan6Characters: (context, event) => {
|
|
90
|
-
// return context.password.length < 6
|
|
91
|
-
},
|
|
92
|
-
},
|
|
93
74
|
services: {
|
|
94
|
-
|
|
95
|
-
const {
|
|
75
|
+
authenticate: async (context, event) => {
|
|
76
|
+
const { channel, subchannel, signUpData } = context
|
|
96
77
|
const dt = await getDeviceToken({ fpToken, sentry, apiURL: request.config.apiURL })
|
|
78
|
+
|
|
97
79
|
return await request.send(
|
|
98
80
|
auth.register({
|
|
99
|
-
|
|
100
|
-
email,
|
|
101
|
-
password,
|
|
81
|
+
...signUpData,
|
|
102
82
|
channel: cookies.get('channel') || channel,
|
|
103
83
|
subchannel: cookies.get('subchannel') || subchannel,
|
|
104
84
|
dt,
|