@@ -130,34 +130,44 @@ export class Oauth2Auth extends AlfrescoApiClient {
130130
131131 discoveryUrls ( ) {
132132 return new Promise ( ( resolve , reject ) => {
133- let postBody = { } , pathParams = { } , queryParams = { } , formParams = { } , headerParams = { } ;
134- let contentTypes = [ 'application/json' ] ;
135- let accepts = [ 'application/json' ] ;
136-
137- let url = '.well-known/openid-configuration' ;
138- this . callApi (
139- url , 'GET' ,
140- pathParams , queryParams , headerParams , formParams , postBody ,
141- contentTypes , accepts
142- ) . then ( ( discovery ) => {
143- this . discovery = { } ;
144- this . discovery . loginUrl = discovery . authorization_endpoint ;
145- this . discovery . logoutUrl = discovery . end_session_endpoint ;
146- this . discovery . grantTypesSupported = discovery . grant_types_supported ;
147- this . discovery . issuer = discovery . issuer ;
148- this . discovery . tokenEndpoint = discovery . token_endpoint ;
149- this . discovery . userinfoEndpoint = discovery . userinfo_endpoint ;
150- this . discovery . jwksUri = discovery . jwks_uri ;
151- this . discovery . sessionCheckIFrameUrl = discovery . check_session_iframe ;
133+ let discoveryStore = this . storage . getItem ( 'discovery' ) ;
134+ if ( discoveryStore ) {
135+ this . discovery = JSON . parse ( discoveryStore ) ;
136+ }
152137
138+ if ( ! this . discovery ) {
139+ let postBody = { } , pathParams = { } , queryParams = { } , formParams = { } , headerParams = { } ;
140+ let contentTypes = [ 'application/json' ] ;
141+ let accepts = [ 'application/json' ] ;
142+
143+ let url = '.well-known/openid-configuration' ;
144+ this . callApi (
145+ url , 'GET' ,
146+ pathParams , queryParams , headerParams , formParams , postBody ,
147+ contentTypes , accepts
148+ ) . then ( ( discovery ) => {
149+ this . discovery = { } ;
150+ this . discovery . loginUrl = discovery . authorization_endpoint ;
151+ this . discovery . logoutUrl = discovery . end_session_endpoint ;
152+ this . discovery . grantTypesSupported = discovery . grant_types_supported ;
153+ this . discovery . issuer = discovery . issuer ;
154+ this . discovery . tokenEndpoint = discovery . token_endpoint ;
155+ this . discovery . userinfoEndpoint = discovery . userinfo_endpoint ;
156+ this . discovery . jwksUri = discovery . jwks_uri ;
157+ this . discovery . sessionCheckIFrameUrl = discovery . check_session_iframe ;
158+
159+ this . emit ( 'discovery' , this . discovery ) ;
160+ this . storage . setItem ( 'discovery' , JSON . stringify ( this . discovery ) ) ;
161+ resolve ( discovery ) ;
162+ } , ( error ) => {
163+ this . emit ( 'error' , error ) ;
164+ this . storage . removeItem ( 'discovery' ) ;
165+ reject ( error . error ) ;
166+ } ) ;
167+ } else {
153168 this . emit ( 'discovery' , this . discovery ) ;
154- this . storage . setItem ( 'discovery' , JSON . stringify ( this . discovery ) ) ;
155- resolve ( discovery ) ;
156- } , ( error ) => {
157- this . emit ( 'error' , error ) ;
158- this . storage . removeItem ( 'discovery' ) ;
159- reject ( error . error ) ;
160- } ) ;
169+ resolve ( this . discovery ) ;
170+ }
161171 } ) ;
162172
163173 }
0 commit comments