Created
June 6, 2014 18:45
-
-
Save jrhe/86df5a03d2f88c1b6ac3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Ember.SimpleAuth.Authenticators.OAuth2.reopen({ | |
serverTokenEndpoint: ENV.api.host + '/' + ENV.api.namespace + '/oauth/token', | |
restore: function(properties) { | |
return new Ember.RSVP.Promise(function(resolve, reject) { | |
if (!Ember.isEmpty(properties.user_token) && | |
!Ember.isEmpty(properties.user_email) && | |
!Ember.isEmpty(properties.resource_owner_id)) { | |
resolve(properties); | |
} else { | |
reject(); | |
} | |
}); | |
}, | |
}); | |
export default { | |
name: 'authentication', | |
initialize: function(container, application) { | |
// customize the session so that it allows access to the account object | |
Ember.SimpleAuth.Session.reopen({ | |
user: function() { | |
var userId = this.get('resource_owner_id'); | |
if (!Ember.isEmpty(userId)) { | |
return container.lookup('store:main').find('user', userId); | |
} | |
}.property('resource_owner_id') | |
}); | |
Ember.SimpleAuth.setup(container, application, { | |
authorizerFactory: 'ember-simple-auth-authorizer:oauth2-bearer' | |
}); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment