0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixup behavior and styling of editor re-auth.

Closes #2092
- Adds styling for re-auth modal.
- Prevent transition to posts route on success.
- Clear credentials from controller.
- Handle confirmAccept action if form is submitted via 'enter'.
- Only allow re-auth as the user that was previously logged in.
This commit is contained in:
Jason Williams 2014-12-08 00:31:24 +00:00
parent 569c185de7
commit 5ac4bf1c3c
5 changed files with 72 additions and 16 deletions

View file

@ -166,3 +166,38 @@
.modal-style-centered { .modal-style-centered {
text-align: center; text-align: center;
} }
// Modal login styles
.modal-body .login-form {
display: block; // Override inherited `display: table-cell;`
.password-wrap {
input {
width: 100%;
}
}
@media (max-width: 900px) {
margin: 0 auto;
max-width: 264px;
.password-wrap {
width: 100%;
margin: 0 auto 1em;
}
.btn {
margin: 0;
width: 100%;
margin-bottom: 1em;
}
}
@media (min-width: 901px) {
display: flex;
.password-wrap {
flex: 1;
}
}
}

View file

@ -1,12 +1,30 @@
import SigninController from '../signin'; import SigninController from 'ghost/controllers/signin';
export default SigninController.extend({ export default SigninController.extend({
needs: 'application',
identification: Ember.computed('session.user.email', function () {
return this.get('session.user.email');
}),
actions: { actions: {
authenticate: function (data) { authenticate: function () {
var self = this; var appController = this.get('controllers.application'),
this._super(data).then(function () { self = this;
appController.set('skipAuthSuccessHandler', true);
this._super().then(function () {
self.send('closeModal'); self.send('closeModal');
self.notifications.showSuccess('Login successful.');
self.set('password', '');
}).finally(function () {
appController.set('skipAuthSuccessHandler', undefined);
}); });
},
confirmAccept: function () {
this.send('validateAndAuthenticate');
} }
} }
}); });

View file

@ -15,7 +15,7 @@ AuthenticationInitializer = {
window.ENV['simple-auth'] = { window.ENV['simple-auth'] = {
authenticationRoute: 'signin', authenticationRoute: 'signin',
routeAfterAuthentication: 'content', routeAfterAuthentication: 'posts',
authorizer: 'simple-auth-authorizer:oauth2-bearer', authorizer: 'simple-auth-authorizer:oauth2-bearer',
localStorageKey: 'ghost' + (Ghost.subdir.indexOf('/') === 0 ? '-' + Ghost.subdir.substr(1) : '') + ':session' localStorageKey: 'ghost' + (Ghost.subdir.indexOf('/') === 0 ? '-' + Ghost.subdir.substr(1) : '') + ':session'
}; };
@ -27,9 +27,9 @@ AuthenticationInitializer = {
}; };
SimpleAuth.Session.reopen({ SimpleAuth.Session.reopen({
user: function () { user: Ember.computed(function () {
return container.lookup('store:main').find('user', 'me'); return container.lookup('store:main').find('user', 'me');
}).property() })
}); });
SimpleAuth.Authenticators.OAuth2.reopen({ SimpleAuth.Authenticators.OAuth2.reopen({

View file

@ -63,7 +63,13 @@ ApplicationRoute = Ember.Route.extend(SimpleAuth.ApplicationRouteMixin, Shortcut
}, },
sessionAuthenticationSucceeded: function () { sessionAuthenticationSucceeded: function () {
var self = this; var appController = this.controllerFor('application'),
self = this;
if (appController && appController.get('skipAuthSuccessHandler')) {
return;
}
this.store.find('user', 'me').then(function (user) { this.store.find('user', 'me').then(function (user) {
self.send('signedIn', user); self.send('signedIn', user);
var attemptedTransition = self.get('session').get('attemptedTransition'); var attemptedTransition = self.get('session').get('attemptedTransition');

View file

@ -1,14 +1,11 @@
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade" {{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide" animation="fade"
title="Please login again" confirm=confirm}} title="Please re-authenticate" confirm=confirm}}
<form id="login" class="login-form" method="post" novalidate="novalidate" {{action 'validateAndAuthenticate' on='submit'}}> <form id="login" class="login-form" method="post" novalidate="novalidate" {{action "validateAndAuthenticate" on="submit"}}>
<div class="email-wrap">
{{input class="email" type="email" placeholder="Email Address" name="identification" autofocus="autofocus" autocapitalize="off" autocorrect="off" value=identification}}
</div>
<div class="password-wrap"> <div class="password-wrap">
{{input class="password" type="password" placeholder="Password" name="password" value=password}} {{input class="password" type="password" placeholder="Password" name="password" value=password}}
</div> </div>
<button class="button-save" type="submit" {{action "validateAndAuthenticate"}} {{bind-attr disabled=submitting}}>Log in</button> <button class="btn btn-blue" type="submit" {{action "validateAndAuthenticate"}} {{bind-attr disabled=submitting}}>Log in</button>
</form> </form>
{{/gh-modal-dialog}} {{/gh-modal-dialog}}