Simple Auth redirect

Hey so I have simple auth and I want my index page to be only for users that are logged in and instead of redirecting them to the login page I want them to be redirected to my welcome page. All other pages that they are not authorized to use i want them still sent to the login page. It is only different for my index page. I tried doing an if statement and a redirect in the index.js route but nothing seems to work. I would really appreciate the help. Thanks in advance.

UPDATE

ok so I did some research and I figured out what i needed to do by I cant seem to get it working.

import Ember from 'ember';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import Configuration from 'ember-simple-auth/configuration';
import ENV from 'myApp/config/environment';

ENV['ember-simple-auth'] = {
  authenticationRoute: 'welcome'
};

export default Ember.Route.extend(AuthenticatedRouteMixin);

so i tried to change the configuration and have it redirect to a welcome page like so. However it still brings me to the login page. What am I doing wrong?

You should use AuthorizedRouteMixin and UnauthorizedRouteMixin for your routes. It is covered in simple auth documentation.

yes I am aware thank you. I was saying though that I wanted to redirect to a different page other than the login for only that page though. that is the issue I am having.

I think you should be able to use session as a service and determine whether user is signed in and do redirect in Route definition. Can you paste what have you tried so far?

Any updates on this topic?

I have same question.

Following the setup. First add ApplicationRouteMixin to your Application Route. (ApplicationRouteMixin - ember-simple-auth)[ApplicationRouteMixin]

Add the configuration in your env

// config/environment.js

    'ember-simple-auth': {
      routeAfterAuthentication: 'admin.dashboard',
      routeIfAlreadyAuthenticated: 'admin.dashboard',
    },

I reset de admin route to ‘/’ and add de AuthenticatedRouteMixin. Every route under admin is secureted.

This method no longer works. The mixin code has changed:

https://github.com/simplabs/ember-simple-auth/blob/master/addon/mixins/authenticated-route-mixin.js#L65-L76

and it no longer accesses the config. What’s the right way of doing this? I have tried subclassing the mixin like this:

import Route from '@ember/routing/route';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';

export default class RequireLoginRoute extends Route.extend(AuthenticatedRouteMixin) {
  authenticationRoute = 'auth/login';
}

I get the error:

 Error: Assertion Failed: Expected hash or Mixin instance, got [object Function]