AngularJS-OAuth2 icon indicating copy to clipboard operation
AngularJS-OAuth2 copied to clipboard

Initialization of the oauth2 directive before endpoint values are established

Open pinnprophead opened this issue 10 years ago • 1 comments

The problem I had was that since the init for the oauth2.endpoint was being called when the directive was loaded, my values for the urls were not being used -- my bootstrap process determines the urls and so they are not known right away.

For example:

    <oauth2 authorization-url="{{loginEndpoint}}"
            sign-out-url="{{logoutEndpoint}}"
            sign-out-append-token="true"
            client-id="{{appKey}}"
            redirect-url="{{redirectEndpoint}}"
            sign-out-redirect-url="{{redirectEndpoint}}"
            sign-in-text="Log In"
            sign-out-text="Log Out"
            response-type="id_token token"
            scope="openid profile email roles all_claims">
    </oauth2>

In order to fix it, I just re-called init for the oauth2.endpoint module in the directive's login method. I hope that makes sense -- it doesn't seem like it would be very expensive...

This is just an FYI -- not sure if you want to take any action on it.

pinnprophead avatar Oct 07 '15 18:10 pinnprophead

Why not using an ng-if on the oauth2 tag with a flag (or even a value) ?

The ng-if disable the component and prevent interpretation of directive.

For example :

   <oauth2 ng-if="loginEndpoint" authorization-url="{{loginEndpoint}}"
            sign-out-url="{{logoutEndpoint}}"
            sign-out-append-token="true"
            client-id="{{appKey}}"
            redirect-url="{{redirectEndpoint}}"
            sign-out-redirect-url="{{redirectEndpoint}}"
            sign-in-text="Log In"
            sign-out-text="Log Out"
            response-type="id_token token"
            scope="openid profile email roles all_claims">
    </oauth2>

davinkevin avatar Jan 25 '16 11:01 davinkevin