Last active
September 11, 2015 12:54
-
-
Save straydogstudio/b81406fb8ca29e12f95a to your computer and use it in GitHub Desktop.
This file contains 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
import Ember from "ember"; | |
// This is an error. It should be 'ember-simple-auth/authenticators/base' | |
// Left to link to a github comment | |
import Base from 'ember-simple-auth/authorizers/base'; | |
export default Base.extend({ | |
tokenEndpoint: '/api/user_sessions', | |
authenticate: function(credentials) { | |
var _this = this; | |
return new Ember.RSVP.Promise(function(resolve, reject) { | |
Ember.$.ajax({ | |
url: _this.tokenEndpoint, | |
type: 'POST', | |
data: JSON.stringify({ | |
username: credentials.identification, | |
password: credentials.password | |
}), | |
contentType: 'application/json' | |
}).then(function(response) { | |
Ember.run(function() { | |
resolve({ token: response.token }); | |
}); | |
}, function(xhr) { | |
var response = JSON.parse(xhr.responseText); | |
Ember.run(function() { | |
reject(response.error); | |
}); | |
}); | |
}); | |
}, | |
restore: function(data) { | |
return new Ember.RSVP.Promise(function (resolve, reject) { | |
resolve(data); | |
}); | |
}, | |
invalidate: function(data) { | |
return new Ember.RSVP.Promise(function (resolve, reject) { | |
resolve(); | |
}); | |
}, | |
// on: function(event, callback) { | |
// console.log('on'); | |
// console.log(callback.toString()); | |
// }, | |
// off: function() {} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note, this is in error. It should be extended from "ember-simple-auth/authenticators/base" not "ember-simple-auth/authorizers/base".