mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-26 20:34:02 +03:00
457a8e2955
closes https://github.com/TryGhost/Ghost/issues/10995 - when first loading the site preview, if private mode is enabled submit the login form in the background to get the cookie before loading the iframe - refactors post-authentication preloading to ensure it occurs before post-authentication route hooks are called - adds `showSuccess` attribute to `<GhTaskButton>` so that when set to `false` it can stay in the running state after "success" to avoid state change flashes whilst waiting for a transition
40 lines
1.0 KiB
JavaScript
40 lines
1.0 KiB
JavaScript
import AuthenticatedRoute from 'ghost-admin/routes/authenticated';
|
|
import fetch from 'fetch';
|
|
import {inject as service} from '@ember/service';
|
|
|
|
export default AuthenticatedRoute.extend({
|
|
config: service(),
|
|
settings: service(),
|
|
ui: service(),
|
|
|
|
_hasLoggedIn: false,
|
|
|
|
model() {
|
|
return (new Date()).valueOf();
|
|
},
|
|
|
|
afterModel() {
|
|
if (this.settings.get('isPrivate') && !this._hasLoggedIn) {
|
|
let privateLoginUrl = `${this.config.get('blogUrl')}/private/?r=%2F`;
|
|
|
|
return fetch(privateLoginUrl, {
|
|
method: 'POST',
|
|
mode: 'cors',
|
|
redirect: 'manual',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded'
|
|
},
|
|
body: `password=${this.settings.get('password')}`
|
|
}).then(() => {
|
|
this._hasLoggedIn = true;
|
|
});
|
|
}
|
|
},
|
|
|
|
buildRouteInfoMetadata() {
|
|
return {
|
|
titleToken: 'Site'
|
|
};
|
|
}
|
|
});
|