knacktim commented on pull request #573:
URL: https://github.com/apache/guacamole-client/pull/573#issuecomment-786011286


   
   ```js
   angular.module('openid').run(['$routeParams', 'authenticationService', 
       function openIDLogoutListener($routeParams, authenticationService) {
   
       let config = {} // TODO get these from backend
   
       authenticationService.registerLogoutHandler((resolve, reject) => {
         if ($routeParams && Object.prototype.hasOwnProperty.call($routeParams, 
'id_token')) {
           $.get({
             url: config['openid_logout_endpoint'],
             dataType: 'application/json',
             async: false,
             data: {
               client_id: config['openid_client_id'],
               id_token_hint: $routeParams.id_token
             },
             success: function(resp) {
               resolve("Success");
             },
             error: function() {
               reject("Error when trying to log out");
             }
           })
         }
       })
   
   }]);
   ```
   
   @mike-jumper  
   > I'd think either implementation would allow an extension to reliably hook 
into application logout. Is your concern that you want to be able to manually 
reject the promise returned by `authenticationService.logout()` from within a 
logout hook?
   
   Looking at the above use case as an example.  I am focusing on this part 
here:
   
https://github.com/apache/guacamole-client/blob/5319f9011a0cca5b024709adb9a512c2d1070e90/guacamole-common-js/src/main/webapp/modules/Event.js#L217-L230
   
   If users do any async REST calls inside of a `relevantListener` I need the 
`dispatch` method to return a Promise.all() promise to the caller so that if 
needed, they can trigger a `.then()` after they are sure all of the listeners 
have been handled the event.  Otherwise I think there is a risk that we 
propagate the event, then the page could get refreshed before we are sure that 
the handler was finished.
   
   I don't think we care if the action was `resolve` or `reject`, we just need 
a hook to tell us when the listener is done.
   
   It is totally possible that I am overthinking this :zany_face: 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to