Clean up password reset

This commit is contained in:
Matthew Dillon 2015-10-27 16:17:18 -07:00
parent 8e11942521
commit 1605f34dcc
7 changed files with 35 additions and 18 deletions

View file

@ -1,19 +1,29 @@
// Note: this is here for user lockout authentication
// Note: this authenticator exists for user lockout --- they are sent a copy
// of a valid JWT to their registered email address. The lockout route plucks
// the token off the URL and passes it directly into this authenticator.
import BaseAuthenticator from 'ember-simple-auth/authenticators/base';
import Ember from 'ember';
import JwtTokenAuthenticator from 'simple-auth-token/authenticators/jwt';
export default JwtTokenAuthenticator.extend({
const { RSVP, isEmpty } = Ember;
export default BaseAuthenticator.extend({
authenticate: function(token) {
return new Ember.RSVP.Promise(resolve => {
let tokenData = this.getTokenData(token);
let expiresAt = tokenData[this.tokenExpireName];
let response = {};
response[this.tokenPropertyName] = token;
response.expiresAt = expiresAt;
this.scheduleAccessTokenRefresh(expiresAt, token);
resolve(this.getResponseData(response));
return new RSVP.Promise((resolve, reject) => {
if (isEmpty(token)) {
reject();
} else {
// For now assume that the token we have received is actually valid.
resolve({'access_token': token});
}
});
},
restore: function(data) {
return RSVP.resolve(data);
},
invalidate: function(data) {
return RSVP.resolve();
},
});