samedi 3 décembre 2016

The general validating process of user tokens in web projects with Polymer & Firebase

I am fairly new to JavaScript and decided to build a project with Polymer & Firebase. My plan is to hide specific pages to users that are not signed-up on my page yet. I came across a problem that I believe is related to my approach. However, due to the lack of experience I don't know whats the right way tackle this task. It would be great if someone is willing to point out my mistakes or is able to provide me with some resources that I could study.

The problem
When user register on my page with the Google sign-up provided by Firebase I store the UID of the user in the Polymer localstorage. On other pages I now want to check if the UID exists or not. However, if I am using the created function which is part of the Polymer lifecycle, properties & elements including my localstorage are not created yet. Which makes it impossible to validate the UID.

  created: function() {
    console.log(this.localName + '#' + this.id + ' was created');
  },

But using the ready function is no option either because this would allow a unregistered user to view the page for a small amount of time.

I am now wondering how this is handeled in general in web projects because I believe my approach must be wrong. Or in case this is a way of doing it what could I change to avoid my problem.




Aucun commentaire:

Enregistrer un commentaire