Simple Auth redirect


#1

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?


#2

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


#3

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.


#4

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?


#5

Any updates on this topic?

I have same question.


#6

Following the setup. First add ApplicationRouteMixin to your Application Route. (http://ember-simple-auth.com/api/classes/ApplicationRouteMixin.html)[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.