diff --git a/tools/public/assets/cropper/app.js b/tools/public/assets/cropper/app.js index f33e22d..6f2a415 100644 --- a/tools/public/assets/cropper/app.js +++ b/tools/public/assets/cropper/app.js @@ -2,6 +2,7 @@ Identity comes from the YOUreka session; the only operator credential is the save-time OTP (required by a2loft). Notifications are Carbon toasts. */ /* global Vue, axios, Croppa, customElements */ +/* window.__SESSION__ is injected server-side by /cropper */ Vue.config.ignoredElements = [/^cds-/]; (function () { @@ -69,17 +70,13 @@ Vue.config.ignoredElements = [/^cds-/]; created: function () { var self = this; - axios.get('/auth/session').then(function (r) { - self.session = r.data; - self.loading = false; - }).catch(function (err) { - if (err.response && err.response.status === 401) { - window.location.href = '/auth/login'; - return; - } - self.loading = false; - self.toast('error', 'Session error', 'Could not load your session. Please refresh the page.'); - }); + // injected by the server when the page was rendered (no round-trip) + this.session = window.__SESSION__ || null; + if (!this.session) { + window.location.href = '/auth/login'; + return; + } + this.loading = false; Promise.all( ['cds-button', 'cds-toast', 'cds-toast-item', 'cds-tag'].map(function (n) { return customElements.whenDefined(n).catch(function () {}); diff --git a/tools/public/assets/fp/app.js b/tools/public/assets/fp/app.js index 305a662..3e67330 100644 --- a/tools/public/assets/fp/app.js +++ b/tools/public/assets/fp/app.js @@ -1,6 +1,7 @@ /* Fingerprint Agent — enrollment wizard. Captures run through the local fpagent binary; artifacts are saved via the app's a2loft proxy. */ /* global Vue, axios, io, customElements */ +/* window.__SESSION__ is injected server-side by /fingerprint */ Vue.config.ignoredElements = [/^cds-/]; (function () { @@ -102,19 +103,17 @@ Vue.config.ignoredElements = [/^cds-/]; }, loadSession: function () { - var self = this; - return axios.get('/auth/session').then(function (r) { - self.session = r.data; - if (self.session.domains.length) self.domain = self.session.domains[0].code; - self.loading = false; - }).catch(function (err) { - if (err.response && err.response.status === 401) { - window.location.href = '/auth/login'; - return; - } - self.loading = false; - self.showNotif('error', 'Session error', 'Could not load your session. Please refresh the page.', true); - }); + // injected by the server when the page was rendered (no round-trip) + this.session = window.__SESSION__ || null; + if (!this.session) { + window.location.href = '/auth/login'; + return Promise.resolve(); + } + if (this.session.domains && this.session.domains.length) { + this.domain = this.session.domains[0].code; + } + this.loading = false; + return Promise.resolve(); }, refreshDomains: function () { diff --git a/tools/public/index.html b/tools/public/index.html index 9a1ac15..cc902e8 100644 --- a/tools/public/index.html +++ b/tools/public/index.html @@ -22,9 +22,7 @@ YOUreka Tools -
+ @@ -69,30 +67,5 @@ Scan captures run locally via the fpagent agent — no scanner data leaves this machine except the enrolled artifacts you save. -