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://example.co.in/api/socialsignup/',
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://example.co.in/api/post/signupdone"
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.
You can save data in the session's data
by just setting it:
this.get('session').set('data.signupDone', true);
That way signupDone
will be persisted (also when the session is invalidated). Of course if the user logs in in another browser that data won't be present anymore so you should probably store the property in a resource on the server side instead.