Last active
December 19, 2015 08:38
-
-
Save overture8/5926689 to your computer and use it in GitHub Desktop.
Ember devise auth
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
# initializers/current_user.js.coffee | |
Ember.Application.initializer | |
name: 'currentUser' | |
initialize: (container) -> | |
attributes = $('meta[name="current-user"]').attr('content') | |
if attributes | |
json = JSON.parse(attributes) | |
if attributes | |
user = App.User.createRecord(email: json.user.email, id: json.user.id) | |
controller = container.lookup('controller:currentUser').set('content', user) | |
container.typeInjection('controller', 'currentUser', 'controller:currentUser') |
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
# controllers/current_user_controller.js.coffee | |
App.CurrentUserController = Ember.ObjectController.extend | |
isSignedIn: (-> | |
@get('content') != null | |
).property('@content') |
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
# models/user.js.coffee | |
App.User = DS.Model.extend | |
email: DS.attr 'string' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment