Skip to content

Commit

Permalink
Update with async/await example
Browse files Browse the repository at this point in the history
  • Loading branch information
geekygrappler authored and marcoow committed Nov 6, 2019
1 parent a275c12 commit 287678a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,17 @@ export default Ember.Controller.extend({
session: Ember.inject.service('session'),

actions: {
authenticate() {
async authenticate() {
let { identification, password } = this.getProperties('identification', 'password');
this.get('session').authenticate('authenticator:oauth2', identification, password).catch((reason) => {
this.set('errorMessage', reason.error || reason);
});
try {
await this.session.authenticate('authenticator:oauth2', identification, password);
} catch(error) {
this.set('errorMessage', error.error || error);
}

if (this.session.isAuthenticated) {
// What to do with all this success?
}
}
}
});
Expand Down

0 comments on commit 287678a

Please sign in to comment.