0

I am trying to work out how to do the following:

Situation: User opens website.com

A) If user is logged in, he is shown the "welcome template".

B) If user is not logged in, he is shown the "login template".

I don't want to URL in the browser to change, it should stay as website.com for both outcomes.

How can I get this route setup?

3
  • 1
    what is wrong with a /login route, if the entire template is going to change anyway? Commented Aug 13, 2014 at 14:04
  • Nothing, this is just something I've been asked to do. Commented Aug 13, 2014 at 14:30
  • I should also add that the "login" template also acts are the homepage for the product. Example: Facebook.com, you get a homepage is not logged in, the news feed if you are. Commented Aug 13, 2014 at 14:30

1 Answer 1

2

You can use an if statement. You'd need to put the isNotLoggedIn logic on the appropriate controller (probably application).

{{#if isNotLoggedIn}}
  {{render 'login'}}
{{/if}}

I do agree with Grapho though, this is an anti-pattern in Ember (where a url represents what you will see), and doesn't do a good job of separating your concerns (single responsibility). But if you are being told to do it and have no say in the matter.

Sign up to request clarification or add additional context in comments.

2 Comments

if i remember that embercast correctly, there is a block of logic after the ajax post() method where you can handle success and fail response from the server. that is where the session token is set up, and probably where you would toggle the "isNotLoggedIn" property as well.
Thanks kingpin2k and Grapho. I have had a word with the client and explained that is goes against design patterns in not only Ember but also undermines the whole point of URLS!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.