Fix auth verification flow and alert ID fallback
This commit is contained in:
@@ -148,11 +148,14 @@ export function loginPageData(store) {
|
||||
userLogin: this.form.userLogin.trim(),
|
||||
});
|
||||
this.syncFromStore();
|
||||
|
||||
store.addAlert({
|
||||
type: 'info',
|
||||
message: `Got secret key starting ${store.session.applicationKey.slice(0, 8)}.... Approve this key in Tryton preferences.`,
|
||||
});
|
||||
try {
|
||||
store.addAlert({
|
||||
type: 'info',
|
||||
message: `Got secret key starting ${store.session.applicationKey.slice(0, 8)}.... Approve this key in Tryton preferences.`,
|
||||
});
|
||||
} catch (error) {
|
||||
console.warn('Alert display failed after successful key creation.', error);
|
||||
}
|
||||
});
|
||||
},
|
||||
async checkConnection() {
|
||||
@@ -160,12 +163,20 @@ export function loginPageData(store) {
|
||||
await window.__loncApp.verifyConnection();
|
||||
this.syncFromStore();
|
||||
if (store.isConnected) {
|
||||
this.verifyState.error = '';
|
||||
store.addAlert({ type: 'success', message: 'Kitchen application key is active.' });
|
||||
navigate('/');
|
||||
}
|
||||
}).catch(() => {
|
||||
}).catch((error) => {
|
||||
if (store.isConnected) {
|
||||
this.verifyState.error = '';
|
||||
return;
|
||||
}
|
||||
const status = error?.cause?.status || error?.status;
|
||||
this.verifyState.error =
|
||||
'Failed to verify connection. Please verify the application key in Tryton first.';
|
||||
status === 403
|
||||
? 'Failed to verify connection. Please verify the application key in Tryton first.'
|
||||
: (error?.message || this.verifyState.error || 'Failed to verify connection.');
|
||||
});
|
||||
},
|
||||
async tryAutoVerify() {
|
||||
@@ -179,6 +190,7 @@ export function loginPageData(store) {
|
||||
|
||||
this.syncFromStore();
|
||||
if (store.isConnected) {
|
||||
this.verifyState.error = '';
|
||||
await window.__loncApp.refreshKitchens();
|
||||
navigate('/');
|
||||
}
|
||||
@@ -223,6 +235,9 @@ export function loginPageData(store) {
|
||||
this.sessionState = store.session?.state || CONNECTION_STATES.notConnected;
|
||||
this.applicationKey = store.session?.applicationKey || '';
|
||||
this.form.userLogin = store.session?.userLogin || this.form.userLogin;
|
||||
if (this.sessionState === CONNECTION_STATES.connected) {
|
||||
this.verifyState.error = '';
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user