Last active
August 29, 2015 14:15
-
-
Save ultimatemonty/372b1d405a65dd871735 to your computer and use it in GitHub Desktop.
currentUser into routes and controllers via Session
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.AppSession = SimpleAuth.Session.extend({ | |
currentUser: Ember.computed('userId', function () { | |
var userId = this.get('userId'); | |
if (!Ember.isEmpty(userId)) { | |
return this.container.lookup('store:main').find('user', userId); | |
} | |
}) | |
}); |
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.ApplicationRoute = Ember.Route.extend({ | |
currentUser: Ember.computed.alias(this.get('session.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
/* | |
* Ember Simple Auth ServiceStack CredentialsProvider Authenticator and Authorizer | |
*/ | |
Ember.Application.initializer({ | |
name: 'simple-auth-servicestack', | |
before: 'simple-auth', | |
initialize: function(container, application) { | |
container.register('session:custom', App.AppSession); | |
container.register('authorizer:servicestack', App.SimpleAuthServiceStackCredentialAuthorizer); | |
container.register('authenticator:servicestack', App.SimpleAuthServiceStackCredentialAuthenticator); | |
// Init the ENV var | |
window.ENV = window.ENV || {}; | |
// Simple Auth config | |
window.ENV['simple-auth'] = { | |
session: 'session:custom', | |
authenticationRoute: 'login', | |
routeAfterAuthentication: 'application.home', | |
routeIfAlreadyAuthenticated: 'application.home', | |
store: 'simple-auth-session-store:cookie', | |
authorizer: 'authorizer:servicestack' | |
}; | |
} | |
}); |
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.User = DS.Model.extend({ | |
uniqueId: string, | |
userName: string, | |
password: string, | |
firstName: string, | |
lastName: string, | |
emailAddress: string, | |
employeeNumber: string, | |
department: string, | |
jobPosition: string, | |
isActive: bool, | |
clearActivation: bool, | |
activationId: string, | |
activationExpires: string, | |
profilePictureUrl: string, | |
passwordResetId: string, | |
passwordReset: bool, | |
clearPasswordReset: bool, | |
lastPasswordResetBy: DS.belongsTo('user', { async: true, inverse: null }), | |
lastPasswordResetDate: string, | |
createdBy: DS.belongsTo('user', { async: true, inverse: null }), | |
createdDate: string, | |
modifiedBy: DS.belongsTo('user', { async: true, inverse: null }), | |
modifiedDate: string, | |
// soft delete | |
isDeletedFromApplication: bool, | |
deletedBy: DS.belongsTo('user', { async: true, inverse: null }), | |
deletedDate: string | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment