mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 07:09:48 +03:00
Show warning dialog if session has ended in editor
Closes #3839 - Display a warning modal in the editor routes if the user is logged out due to re-authorization problems. This provides a chance to copy any unsaved content before being sent to the signin page to log back in.
This commit is contained in:
parent
3132496c6a
commit
61361ac91b
34
ghost/admin/controllers/modals/auth-failed-unsaved.js
Normal file
34
ghost/admin/controllers/modals/auth-failed-unsaved.js
Normal file
@ -0,0 +1,34 @@
|
||||
var AuthFailedUnsavedController = Ember.Controller.extend({
|
||||
editorController: Ember.computed.alias('model'),
|
||||
|
||||
actions: {
|
||||
confirmAccept: function () {
|
||||
var editorController = this.get('editorController');
|
||||
|
||||
if (editorController) {
|
||||
editorController.get('model').rollback();
|
||||
}
|
||||
|
||||
window.onbeforeunload = null;
|
||||
|
||||
window.location = this.get('ghostPaths').adminRoot + '/signin/';
|
||||
},
|
||||
|
||||
confirmReject: function () {
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
confirm: {
|
||||
accept: {
|
||||
text: 'Leave',
|
||||
buttonClass: 'btn btn-red'
|
||||
},
|
||||
reject: {
|
||||
text: 'Stay',
|
||||
buttonClass: 'btn btn-default btn-minor'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
export default AuthFailedUnsavedController;
|
@ -13,6 +13,18 @@ var ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shor
|
||||
},
|
||||
|
||||
actions: {
|
||||
authorizationFailed: function () {
|
||||
var currentRoute = this.get('controller').get('currentRouteName');
|
||||
|
||||
if (currentRoute.split('.')[0] === 'editor') {
|
||||
this.send('openModal', 'auth-failed-unsaved', this.controllerFor(currentRoute));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
this._super();
|
||||
},
|
||||
|
||||
closePopups: function () {
|
||||
this.get('popover').closePopovers();
|
||||
this.get('notifications').closeAll();
|
||||
|
8
ghost/admin/templates/modals/auth-failed-unsaved.hbs
Normal file
8
ghost/admin/templates/modals/auth-failed-unsaved.hbs
Normal file
@ -0,0 +1,8 @@
|
||||
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade"
|
||||
title="Post NOT saved." confirm=confirm}}
|
||||
|
||||
<p>Hey there! Something has gone wrong and you have been logged out. It looks like you have unsaved content that will be lost if you leave this page.</p>
|
||||
|
||||
<p>Copy your content somewhere safe before you go!</p>
|
||||
|
||||
{{/gh-modal-dialog}}
|
Loading…
Reference in New Issue
Block a user