Creating a login page that doesn't use the application.hbs?


I just started writing my ember app and i’m having problems structuring the base routes. My application needs to be protected by a login page that is presented to the user if they are not authenticated. This /login route shouldn’t contain any of the navigation, footers, and side-menu’s that are present in the rest of the whole application. I started off by adding all of those components to the application.hbs which is cool because it is rendered with every route. But for the /login route and potentially any other unauthorized user routes this isn’t the case.

I’ve seen this explanation on stack overflow about it: Unfortunately i don’t have enough reputation to comment and ask for a better explanation.

This post tries to explain it but its not quite doing it for me.

The docs don’t seem to mention resource either.

What would be the best way to set the /login route off on its own?


The way we approached this problem in our app was to define two top-level resources to represent the two different layouts. One for all secured pages, and another for the unsecured login page.


Agreed. I believe this is the way to go. () {
  this.resource('app', { path: '/app' }, function () {
  this.resource('nonapp', { path: '/' }, function () {

Now your application.hbs contains just an {{outlet}}


What is the difference between resource and route? The explanation you use shows resources but it can also be completed the following way.

// Regular authentication protected resources
  this.route('portal', {path: '/'}, function(){


  // Public resources that do not require login
  this.route('public', function(){

      // The main login route
      this.route('login', function() {

It appears resource has been removed from the documentation in 1.11.

Here it is in 1.10: And it is gone in 1.11:


Stand clear from resource(), for its fate is sealed and neck’s already on chopping block. :wink:

Resources allowed you to nest themselves, they also had some extra magic in how their names are handled in neesting (ergo ‘comments’ resource nested within ‘post’ resource was accessible via {{link-to "comments"}} instead of {{link-to "posts.comments"}} (same rule stood for routes/controllers classes implemented for those).

Howefect you can nest routes as well for some time now, and arguably namespace resetting isn’t that much of game changes for devs to keep resource around anymore.


This may be stupid, but works for me. One simple if statement in application.hbs like {{#if isAuth}}… else {{ render ‘login’}} and this is for ember 1.10.0


Authentication as a session property extending controllers and routes, such as the standard for simple-auth and torii. Set a boolean like “isAuth” for when a session is authenticated.

Thus on index route:

redirect: function() {
    if (!this.get('session.isAuth')) {


I’ve also gone the if route:

{{!-- application/template.hbs --}}
{{#if session.isAuthenticated}} 
  app layout

and something similar in index.hbs, so that the index route of shows a welcome/login page for unauthed users, and a “home” page for auth’d users (like twitter, fb, etc.)