mardi 8 décembre 2015

Move to another hbs in ember after the authentication is done

I have an app in which I have include a fb login.I am using ember-simple-auth for authorization and session manganement.I am able to authenticate the user and move to my "feed" hbs .The problem is when I open the app on another tab it is rendering the login page.How do I implement where if the user is authenticated it directly move to "feed" hbs.Similary to facebook,instagram where user login for the first time and after that they are redirect to feed page until they logout.

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://ift.tt/1OfoyLs',
          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;




Aucun commentaire:

Enregistrer un commentaire