Signin after Signup

closes #3125
- added manual authentication after signin
- added manual authentication after setup
This commit is contained in:
Sebastian Gierlinger 2014-06-30 15:34:36 +02:00
parent 9550205d33
commit 1c226dca60
2 changed files with 17 additions and 18 deletions

View File

@ -27,18 +27,17 @@ var SetupController = Ember.ObjectController.extend(ValidationEngine, {
'X-CSRF-Token': self.get('csrf')
},
data: self.getProperties('blogTitle', 'name', 'email', 'password')
}).then(function (resp) {
self.toggleProperty('submitting');
if (resp && resp.userData) {
self.store.pushPayload({ users: [resp.userData]});
self.store.find('user', resp.userData.id).then(function (user) {
}).then(function () {
self.get('session').authenticate('ember-simple-auth-authenticator:oauth2-password-grant', {
identification: self.get('email'),
password: self.get('password')
}).then(function () {
self.store.find('user', 'me').then(function (user) {
self.send('signedIn', user);
self.notifications.clear();
self.transitionToRoute('posts');
self.transitionToRoute(Ember.SimpleAuth.routeAfterAuthentication);
});
} else {
self.transitionToRoute('setup');
}
});
}, function (resp) {
self.toggleProperty('submitting');
self.notifications.showAPIError(resp);

View File

@ -26,17 +26,17 @@ var SignupController = Ember.ObjectController.extend(ValidationEngine, {
'X-CSRF-Token': self.get('csrf')
},
data: self.getProperties('name', 'email', 'password')
}).then(function (resp) {
self.toggleProperty('submitting');
if (resp && resp.userData) {
self.store.pushPayload({ users: [resp.userData]});
self.store.find('user', resp.userData.id).then(function (user) {
}).then(function () {
self.get('session').authenticate('ember-simple-auth-authenticator:oauth2-password-grant', {
identification: self.get('email'),
password: self.get('password')
}).then(function () {
self.store.find('user', 'me').then(function (user) {
self.send('signedIn', user);
self.transitionToRoute('posts');
self.notifications.clear();
self.transitionToRoute(Ember.SimpleAuth.routeAfterAuthentication);
});
} else {
self.transitionToRoute('signin');
}
});
}, function (resp) {
self.toggleProperty('submitting');
self.notifications.showAPIError(resp);