dimanche 7 février 2016

Save data in localstorage of browers in ember simple auth

I have used ember-simple-auth for fb login.I am able fetch the fb's access_token and sending the token to my server for exchange of server token.This works fine and and I am able to make my transition to user feed page.But the problem I am facing is for the first time user.I have to show them some onboarding screen before taking them to their feed screen.And from next time I can skip the onboarding process for them.

torii.js

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/20PDs3w',
          type:     'POST',
          dataType: 'json',
          data:     { 'access_token':data.accessToken,'provider':'facebook'}
        }).then((response) => {
          console.log(response.token);
          resolve({
            // jscs:disable requireCamelCaseOrUpperCaseIdentifiers
            access_token: response.token,
            // jscs:enable requireCamelCaseOrUpperCaseIdentifiers
            provider: data.provider
          });
        }, reject);
      }, reject);
    });
  }
});

The response for I am getting from my server is something like this.

For First Time User.

{access_token:'abcd...',signup_done:false}

When Signup_done is false I have to show user the onboarding screen and the make a POST request to server "http://ift.tt/20PDs3y"

For normal user

{access_token:'abcd...',singup_done:true}

This time I have to just move the user to thier the feed screen skipping the onboarding screen.

I want to save the singup_done from server to my cookie or brower local storage ( not sure ).So that I can use this value in my handlebars,controller,model,component.I am also open to other suggestion to achieve this with simple method.Please use code to example.Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire