You should look into Ember Simple Auth
I am currently using it in an app and have found it very helpful for providing the sort of functionality you require. Using it is as simple as extending each route from a mixin:
// app/routes/application.js
import ApplicationRouteMixin from 'simple-auth/mixins/application-route-mixin';
export default Ember.Route.extend(ApplicationRouteMixin);
This will call you authentication hook (just look at the docs) or redirect to your auth route, where you define login logic.
And then you can wrap things with valid session checks:
{{#if session.isAuthenticated}}
<a {{ action 'invalidateSession' }}>Logout</a>
{{else}}
{{#link-to 'login'}}Login{{/link-to}}
{{/if}}
Session can be passed in as attributes to a component, or can be set on the application controller and access via needs helper in controllers.
As for setting the model, you don't have to use the model hook.
action: {
login: function(userId){
var self = this;
//on fulfillment of promise, set the controller's model
this.store.find('user', userId).then(function(returnedUser){
self.controller.set('model', returnedUser);
}
}
}
This technique relies on an action being sent where the userId is a parameter so that the method is more flexible with a handlebars helper {{action 'login' 1}} or a controller method: this.send('login', 1)
Your login controller could also have a property, userId that gets set on login.
Your login controller, rather than receiving a userId parameter could simply access this property off the login controller with: this.controllerFor('login').get('userId') There's plenty of ways to accomplish what you want. Ember Simple Auth is probably the best, but roll your own if you want