应用子路由的重定向被执行

时间:2016-02-23 13:16:52

标签: ember.js

我有以下情况:

http://example.dev/
http://example.dev/scanstart

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')
    }
})

我遇到的问题如下:

在我的application.hbs(根模板文件)中,我实现 auth-login 组件,当我在http://example.dev/时,我通过 auth-login 组件,如果登录成功,scanstart.js中的 重定向 挂钩正在执行,这怎么可能?

1 个答案:

答案 0 :(得分:0)

这是我的 config / environment.js 文件中的一个设置我忘记了当我安装Ember Simple Auth时我做了它,我的坏!