0

I'd like to "free" one nested route, so that also users who are not even logged in can access this route.

For example:

posts - /create - /edit - /show

On the posts route I used the AuthenticatedRouteMixin. With this, all sub routes are automatically protected. Now I only want to make /show accessable. I know that I could use a mixin on /create and /edit and remove it from posts route, but if you have 10+ nested routes and only 1 of them should be available also for not logged in users, it's kind of inconvenient.

Do you know any other solution to that challenge?

If not, I think I have to write an additional mixin for that...

Thanks!

2 Answers 2

0

ember-simple-auth's AuthenticatedRouteMixin uses beforeModel hook to check whether session.isAuthenticated or not. You need to override the beforeModel in 'show' route to either skip the Auth check by bypassing AuthenticatedRouteMixin's super() implementation all together.

beforeModel (transition, skipAuthCheck) {
    if (!skipAuthCheck) {
       return this._super(...arguments, true);
    }
}

Check if the 'show' beforeModel has dependency with parent route .i.e 'posts', implement this check at the parent route.

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

1 Comment

I'll check it out in the following days. Thanks for now!
0

You could fake a nested route, by using the path parameter:

this.route('posts', function() {
    this.route('create');
    this.route('edit');
});
this.route('posts-show', { path: '/posts/show' });

1 Comment

I definitely want to avoid this because I want to keep my files semantically organized under posts folder. Thanks for replying anyway!

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.