angular-pusher icon indicating copy to clipboard operation
angular-pusher copied to clipboard

PusherService configuration outside config block. Is it possible?

Open willian opened this issue 10 years ago • 1 comments

First of all, thanks for this library @doowb.

I have something like this:

var userAuthenticationToken = window.sessionStorage.authenticationToken;
if (userAuthenticationToken !== '') {
  PusherServiceProvider
    .setToken(PUSHER_KEY)
    .setOptions({
      authEndpoint: API_URL + '/v1/pusher/auth',
      auth: {
        headers: {
          'Authorization': 'Token token=' + userAuthenticationToken
        }
      }
    });
}

That's because my Backend API requires an authenticated user in order to authenticate Pusher.

The problem is: sometimes usre is not logged in, so I show a sign in form to him, he logs in and I can't make a request to authenticate Pusher because .config block can't be called any more.

Is there a way to call PusherService in order to make an authentication again?

Thanks in advance for any help :)

willian avatar Jan 20 '15 20:01 willian

I've been away from angular for a little while. Is there a way to "reload" a ServiceProvider obj in an angular app? If not, I guess I should add a way to do this in a controller. I think a solution for this will resolve a few other issues too.

doowb avatar Apr 23 '15 16:04 doowb