验证完成后移动到 ember 中的另一个 hbs

Move to another hbs in ember after the authentication is done

我有一个应用程序,其中包含一个 fb login.I 我正在使用 ember-simple-auth 进行授权和会话 manganement.I 我能够对用户进行身份验证并转到我的 "feed" hbs 。问题是当我在另一个选项卡上打开应用程序时它正在呈现登录 page.How 我是否实现如果用户通过身份验证它直接移动到 "feed" hbs.Similary 到 facebook、instagram 用户第一次登录,然后他们被重定向到 feed 页面,直到他们注销。

autheticator.js

const { RSVP } = Ember;
const { service } = Ember.inject;

export default Torii.extend({
  torii: service('torii'),

  authenticate() {
    return new RSVP.Promise((resolve, reject) => {
      this._super(...arguments).then((data) => {
        console.log(data.accessToken)
        raw({
          url:      'http://example.com/api/socialsignup/',
          type:     'POST',
          dataType: 'json',
          data:     { 'access_token':'CAAQBoaAUyfoBAEs04M','provider':'facebook'}
        }).then((response) => {
          console.log(response)
          resolve({
            // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
            access_token: response.access_token,
            // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
            provider: data.provider
          });
        }, reject);
      }, reject);
    });
  }
});

router.js

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

var Router = Ember.Router.extend({
  location: config.locationType
});

    Router.map(function() {
        this.route('index',{path:'/'});
        this.route("aboutus",{path:'/aboutus'});
        this.route('feed',{path:'/feed'});
    });

    export default Router;

您需要在登录后首先显示的路由中使用 application-route-mixin.js,并在所有需要登录才能看到的路由中使用 authenticated-route-mixin.js。检查 this example 了解更多信息。