mardi 23 février 2016

Redirect of application child route get's executed

I have the following situation:

http://example.dev/
http://ift.tt/1QvzV2E

router.js

import Ember  from 'ember'
import Config from './config/environment'

const Router = Ember.Router.extend({
    location: Config.locationType
})

Router.map(function()
{
    /* Stripped code...*/
    this.route('scanstart', {path: 'scan'}, function() {

        this.route('dashboard', {path: 'dashboard'})
        this.route('new',       {path: 'nieuw'}, function () {
            this.route('participants', {path: 'deelnemers'})
            this.route('confirm',      {path: 'bevestigen'})
        })
    })
    /* Stripped code...*/
})

export default Router;

scanstart.js

import Ember from 'ember'

export default Ember.Route.extend({
    authService:      Ember.inject.service('session'),
    scanStartService: Ember.inject.service('scanStart'),

    deactivate () {
        this.get('scanStartService').reset()
    },

    redirect (model, transition) {
        // Default variable
        const authService      = this.get('authService')

        // Check if the user is authenticated
        // if he is transition to scanstart.new
        // else transition to register
        if(authService.get('isAuthenticated'))
            this.transitionTo('scanstart.new')
        else
            this.transitionTo('register')
    }
})

The problem that i am encountering is as follow:

In my application.hbs (The root template file) i implement the auth-login component, while i am on http://example.dev/ i login through the auth-login component, if the login succeed the redirect hook in scanstart.js is getting executed, how is this possible?




Aucun commentaire:

Enregistrer un commentaire