title: Best practice for React Router user roles (Firebase)
body: <p>My application will have 2 roles, Employee and Admin.
  I'm trying to implement middleware so users get redirected if they are not authorized to see the content. Is handling not just general authentication but also user roles in React Router good practice?</p>
  
  <p>My first thought was to add a custom role attribute to firebase.auth().currentUser, but adding attributes to currentUser is not allowed by firebase.</p>
  
  <p>If so, how would I do it? 
  Through state or fetching it from my Firebase DB like this?:</p>
  
  <pre><code>var requireEmp = (nextState, replace, next) =&gt; {
   var role;
   var uid = firebase.auth().currentUser.uid;
   firebase.database().ref('/users/' + uid + '/role').once('value').then((user) =&gt; {
    role = user.val().role;
   });
   if (role !== 'employee') {
    replace('/');     
   }
   next();
  };
  </code></pre>
  
  <p>...</p>
  
  <pre><code>&lt;Router history={hashHistory}&gt;
   &lt;Route path="/" &gt;
    &lt;Route path="home" component={Main} onEnter={requireLogin}&gt;
      &lt;Route path="work" component={Work} onEnter={requireEmp}/&gt;
      &lt;Route path="profile" component={Profile} /&gt;
      &lt;IndexRoute component={Profile}/&gt;
    &lt;/Route&gt;
   &lt;/Route&gt;
  &lt;/Router&gt;
  </code></pre>
  
  <p>I'm new to React and Redux and still a bit scared of working with state and important data such as the user role attribute.</p>
  
  <p>What are some other areas I need to be really careful with concerning the implementation of user roles?</p>
  
  <p>Thanks.</p>