mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 03:12:54 +03:00
5d7630607b
closes #3548 - Add error to hidenav, removes menubar from error screen. - Wrap atob() in a try/catch - Added regex to try and validate if params.token at least looks like base64
34 lines
1.3 KiB
JavaScript
34 lines
1.3 KiB
JavaScript
import styleBody from 'ghost/mixins/style-body';
|
|
import loadingIndicator from 'ghost/mixins/loading-indicator';
|
|
|
|
var SignupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
|
classNames: ['ghost-signup'],
|
|
beforeModel: function () {
|
|
if (this.get('session').isAuthenticated) {
|
|
this.notifications.showWarn('You need to sign out to register as a new user.', { delayed: true });
|
|
this.transitionTo(SimpleAuth.Configuration.routeAfterAuthentication);
|
|
}
|
|
},
|
|
setupController: function (controller, params) {
|
|
var tokenText,
|
|
email,
|
|
re = /^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/;
|
|
if (re.test(params.token)) {
|
|
try {
|
|
tokenText = atob(params.token);
|
|
email = tokenText.split('|')[1];
|
|
controller.token = params.token;
|
|
controller.email = email;
|
|
} catch (e) {
|
|
this.transitionTo('signin');
|
|
this.notifications.showError('Invalid token.', {delayed: true});
|
|
}
|
|
} else {
|
|
this.transitionTo('signin');
|
|
this.notifications.showError('Invalid token.', {delayed: true});
|
|
}
|
|
}
|
|
});
|
|
|
|
export default SignupRoute;
|