$ ember install:addon ember-cli-simple-auth
Created
February 17, 2015 12:53
-
-
Save koriroys/b6cff67ca26026834b77 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
// app/sessions/custom.js | |
import Session from 'simple-auth/session'; | |
import Ember from 'ember'; | |
import ENV from 'hivebench-web/config/environment'; | |
export default Session.extend({ | |
currentUser: null, | |
setCurrentUser: function() { | |
// http://emberjs.com/guides/models/finding-records/ | |
// GET /users?uid=XqgfssyI447zz | |
this.container.lookup('store:main').find('user', { uid: authData.uid }).then(function(user) { | |
this.set('currentUser', users.filterBy('uid', authData.uid)[0]) | |
} | |
}.observes('authData.uid') | |
}); |
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
// config/environment.js | |
if (environment === 'development') { | |
ENV['simple-auth'] = { | |
session: "session:custom" | |
} | |
} |
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
// in a controller method | |
this.session.currentUser; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment