eventure-sports / ng-role-auth

Angular.js role based authentication.
BSD 2-Clause "Simplified" License
8 stars 3 forks source link

async version #2

Closed phnx47 closed 9 years ago

phnx47 commented 9 years ago

I create async version. Because, I need get user role from backend, and first page is down.

billstron commented 9 years ago

Thanks for the pull request!

I understand the desire to have async functionality, but I'm not sure about the user experience with this. If you have a request that takes 1s to complete, the page will flash to the blocked page for 1s before being redirected back. This can be tested by adding a timeout in the getRole function in the example app like this:

auth.getRole = function(){
  var deferred = $q.defer();
  $timeout(function(){
    deferred.resolve(self.role);
  }, 1000);
  return deferred.promise;  
};

My feeling is that this temporary flash is unacceptable for something used for security purposes. What do you think?

phnx47 commented 9 years ago

1000ms is not acceptable. I have the answer 10-30ms with network delays. The data is taken from cookie.