@lvce-editor/auth-worker 1.2.0 → 1.3.0
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/dist/authWorkerMain.js +9 -13
- package/package.json +1 -1
package/dist/authWorkerMain.js
CHANGED
|
@@ -997,10 +997,7 @@ const getLoggedOutBackendAuthState = (authErrorMessage = '') => {
|
|
|
997
997
|
return {
|
|
998
998
|
authAccessToken: '',
|
|
999
999
|
authErrorMessage,
|
|
1000
|
-
|
|
1001
|
-
userState: 'loggedOut',
|
|
1002
|
-
userSubscriptionPlan: '',
|
|
1003
|
-
userUsedTokens: 0
|
|
1000
|
+
userState: 'loggedOut'
|
|
1004
1001
|
};
|
|
1005
1002
|
};
|
|
1006
1003
|
|
|
@@ -1193,16 +1190,18 @@ const isLoginResponse = value => {
|
|
|
1193
1190
|
return true;
|
|
1194
1191
|
};
|
|
1195
1192
|
|
|
1196
|
-
const handleClickLogin = async
|
|
1197
|
-
|
|
1193
|
+
const handleClickLogin = async options => {
|
|
1194
|
+
const {
|
|
1195
|
+
backendUrl,
|
|
1196
|
+
platform
|
|
1197
|
+
} = options;
|
|
1198
|
+
if (!backendUrl) {
|
|
1198
1199
|
return {
|
|
1199
|
-
...state,
|
|
1200
1200
|
authErrorMessage: 'Backend URL is missing.',
|
|
1201
1201
|
userState: 'loggedOut'
|
|
1202
1202
|
};
|
|
1203
1203
|
}
|
|
1204
1204
|
const signingInState = {
|
|
1205
|
-
...state,
|
|
1206
1205
|
authErrorMessage: '',
|
|
1207
1206
|
userState: 'loggingIn'
|
|
1208
1207
|
};
|
|
@@ -1211,24 +1210,21 @@ const handleClickLogin = async state => {
|
|
|
1211
1210
|
const response = await consumeNextLoginResponse();
|
|
1212
1211
|
if (!isLoginResponse(response)) {
|
|
1213
1212
|
return {
|
|
1214
|
-
...signingInState,
|
|
1215
1213
|
authErrorMessage: 'Backend returned an invalid login response.',
|
|
1216
1214
|
userState: 'loggedOut'
|
|
1217
1215
|
};
|
|
1218
1216
|
}
|
|
1219
1217
|
if (typeof response.error === 'string' && response.error) {
|
|
1220
1218
|
return {
|
|
1221
|
-
...signingInState,
|
|
1222
1219
|
authErrorMessage: response.error,
|
|
1223
1220
|
userState: 'loggedOut'
|
|
1224
1221
|
};
|
|
1225
1222
|
}
|
|
1226
1223
|
return getLoggedInState(signingInState, response);
|
|
1227
1224
|
}
|
|
1228
|
-
await openUrl(getBackendLoginUrl(
|
|
1229
|
-
const authState = await waitForBackendLogin(
|
|
1225
|
+
await openUrl(getBackendLoginUrl(backendUrl), platform);
|
|
1226
|
+
const authState = await waitForBackendLogin(backendUrl);
|
|
1230
1227
|
return {
|
|
1231
|
-
...signingInState,
|
|
1232
1228
|
...authState
|
|
1233
1229
|
};
|
|
1234
1230
|
} catch (error) {
|