Basic user/session integration

This commit is contained in:
Matthew Dillon 2015-04-10 13:32:44 -08:00
parent 5048fb7695
commit 2b6d7fecbb
4 changed files with 108 additions and 22 deletions

View file

@ -0,0 +1,22 @@
// from: http://blog.willrax.com/fetching-the-current-user-with-simple-auth/
import Ember from "ember";
import Session from "simple-auth/session";
export default {
name: "custom-session",
before: "simple-auth",
initialize: function(container) {
Session.reopen({
setCurrentUser: function() {
var id = this.get("user_id");
var self = this;
if (!Ember.isEmpty(id)) {
return container.lookup("store:main").find("user", id).then(function(user) {
self.set("currentUser", user);
});
}
}.observes("user_id")
});
}
};