diff --git a/ghost/admin/controllers/modals/auth-failed-unsaved.js b/ghost/admin/controllers/modals/auth-failed-unsaved.js new file mode 100644 index 0000000000..a144ecd09c --- /dev/null +++ b/ghost/admin/controllers/modals/auth-failed-unsaved.js @@ -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; diff --git a/ghost/admin/routes/application.js b/ghost/admin/routes/application.js index f06756bd7f..e98c16f009 100644 --- a/ghost/admin/routes/application.js +++ b/ghost/admin/routes/application.js @@ -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(); diff --git a/ghost/admin/templates/modals/auth-failed-unsaved.hbs b/ghost/admin/templates/modals/auth-failed-unsaved.hbs new file mode 100644 index 0000000000..4e2e152e2a --- /dev/null +++ b/ghost/admin/templates/modals/auth-failed-unsaved.hbs @@ -0,0 +1,8 @@ +{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade" + title="Post NOT saved." confirm=confirm}} + +
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.
+ +Copy your content somewhere safe before you go!
+ +{{/gh-modal-dialog}}