From 297ba9e05343c0af0d7ca1dd172651406698b9a0 Mon Sep 17 00:00:00 2001 From: chuanlin2018 Date: Tue, 5 Nov 2024 15:49:25 -0500 Subject: [PATCH] Clean up console log --- libs/oarng/src/lib/auth/auth.service.ts | 147 +++++++++--------- .../lib/wizard/pushingsidebar.component.ts | 5 +- .../src/lib/wizard/slideoutcol.component.ts | 7 +- 3 files changed, 77 insertions(+), 82 deletions(-) diff --git a/libs/oarng/src/lib/auth/auth.service.ts b/libs/oarng/src/lib/auth/auth.service.ts index 8488f2f..f3a3010 100644 --- a/libs/oarng/src/lib/auth/auth.service.ts +++ b/libs/oarng/src/lib/auth/auth.service.ts @@ -12,15 +12,15 @@ const anonymousCreds: Credentials = { }; /** - * the front-end authentication service used to retrieve identity information and to manage - * the authentication process. + * the front-end authentication service used to retrieve identity information and to manage + * the authentication process. * - * This service allows an OAR Angular application to retrieve infomation the currently logged + * This service allows an OAR Angular application to retrieve infomation the currently logged * in user, to log the user in if they are not already logged in, and to retrieve an authentication - * token that can be used to authenticate to other backend services. + * token that can be used to authenticate to other backend services. * - * This abstract class allows for different implementations for different execution - * contexts. In particular, mock versions can be provided for development and testing + * This abstract class allows for different implementations for different execution + * contexts. In particular, mock versions can be provided for development and testing * contexts. */ export abstract class AuthenticationService { @@ -66,10 +66,10 @@ export abstract class AuthenticationService { * return valid credentials. If valid credentials are internally cached, they are returned * for immediate use. Otherwise, credentials are fetched via fetchCredentials(). * - * @param nologin if false (default) and the user is not logged in, an attempt ot log the - * user in will be made. This may cause the browser to be redirected - * to a login service. If this value is true, redirection will not occur; instead, - * the anonymous identity will be set as the credentials. + * @param nologin if false (default) and the user is not logged in, an attempt ot log the + * user in will be made. This may cause the browser to be redirected + * to a login service. If this value is true, redirection will not occur; instead, + * the anonymous identity will be set as the credentials. */ public getCredentials(nologin: boolean = false): Observable { if (this.isAuthenticated()) @@ -89,26 +89,26 @@ export abstract class AuthenticationService { * fetch valid credentials. These credentials may come from a remote authentication * service and may trigger a user log-in process. * - * @param nologin if false (default) and the user is not logged in, an attempt to log the - * user in will be made. This may cause the browser to be redirected - * to a login service. If this value is true, redirection will not occur; instead, - * the anonymous identity will be set as the credentials. + * @param nologin if false (default) and the user is not logged in, an attempt to log the + * user in will be made. This may cause the browser to be redirected + * to a login service. If this value is true, redirection will not occur; instead, + * the anonymous identity will be set as the credentials. */ public abstract fetchCredentials(nologin?: boolean): Observable; /** - * redirect the browser to the authentication service, instructing it to return back to - * this application after the login process is complete. - * @param returnURL the URL to redirect the browser to after a successful login to return to - * to the application. If not provided, window.location.href will be used. - * @return boolean True if the implementation issued a browser redirect; False, otherwise. - * This allows the caller to halt operations if redirection is imminent. + * redirect the browser to the authentication service, instructing it to return back to + * this application after the login process is complete. + * @param returnURL the URL to redirect the browser to after a successful login to return to + * to the application. If not provided, window.location.href will be used. + * @return boolean True if the implementation issued a browser redirect; False, otherwise. + * This allows the caller to halt operations if redirection is imminent. */ public abstract loginUser(returnURL?: string): boolean; } /** - * configuration data describing how to access the remote authentication service assembled in a + * configuration data describing how to access the remote authentication service assembled in a * single object. */ export interface AuthServiceAccessConfig { @@ -120,17 +120,17 @@ export interface AuthServiceAccessConfig { /** * the base URL to redirect to when it is necessary to request that the user log in. If * not provided, a default based on serviceEndpoint will be used. It is expected that this - * URL will require a second URL to be appended to it which represents the URL for gettting + * URL will require a second URL to be appended to it which represents the URL for gettting * back to this application after a successful login. This typically means that the loginURL - * should include queryParameters where that last parameter is for the return URL and ends with - * an equal sign ("="). + * should include queryParameters where that last parameter is for the return URL and ends with + * an equal sign ("="). */ loginBaseURL?: string; /** - * the URL that should be used to redirect the user back to the current application - * from the remote login service after a successful login. If not provided, the current - * value of window.location.href will be used. + * the URL that should be used to redirect the user back to the current application + * from the remote login service after a successful login. If not provided, the current + * value of window.location.href will be used. */ returnURL?: string; } @@ -146,10 +146,10 @@ export interface AuthConfiguration extends Configuration { } /** - * an implementation of the AutenticationService that caches metadata updates on the - * server via a web service. + * an implementation of the AutenticationService that caches metadata updates on the + * server via a web service. * - * This implementation is intended for use in production. + * This implementation is intended for use in production. */ @Injectable({ providedIn: 'root' @@ -157,20 +157,20 @@ export interface AuthConfiguration extends Configuration { export class OARAuthenticationService extends AuthenticationService { /** - * create the AuthService + * create the AuthService */ constructor(protected httpcli: HttpClient, protected configSvc: ConfigurationService) { super() } /** - * the endpoint URL for the customization web service + * the endpoint URL for the customization web service */ - get endpoint(): string { + get endpoint(): string { try { return this.configSvc.getConfig().auth.serviceEndpoint; } catch (ex) { - if (ex instanceof Error) + if (ex instanceof Error) ex.message = "Incomplete auth configuration: missing 'serviceEndpoint' ("+ex.message+")"; throw ex; } @@ -178,10 +178,10 @@ export class OARAuthenticationService extends AuthenticationService { /** * the URL the remote authorization service should redirect to to restart the application - * after routing the browser user through the login service. + * after routing the browser user through the login service. * @param returnURL the URL that the login service should redirect to after a successful login * to return the browser to this application. If not provided, the value - * of window.location.href will be used. + * of window.location.href will be used. */ getLoginURL(returnURL?: string): string { let out : string|null|undefined = null; @@ -205,19 +205,17 @@ export class OARAuthenticationService extends AuthenticationService { * fetch valid credentials. These credentials may come from a remote authentication * service and may trigger a user log-in process. * - * @param nologin if false (default) and the user is not logged in, an attempt to log the - * user in will be made. This may cause the browser to be redirected - * to a login service. If this value is true, redirection will not occur; instead, - * the anonymous identity will be set as the credentials. + * @param nologin if false (default) and the user is not logged in, an attempt to log the + * user in will be made. This may cause the browser to be redirected + * to a login service. If this value is true, redirection will not occur; instead, + * the anonymous identity will be set as the credentials. * @param returnURL the URL that the login service should redirect to after a successful login * to return the browser to this application. If not provided, the value - * of window.location.href will be used. + * of window.location.href will be used. */ public fetchCredentials(nologin: boolean = false, returnURL?: string): Observable { - console.log('this.endpoint', this.endpoint); return this.fetchCredentialsFrom(this.endpoint).pipe( switchMap((c) => { - console.log("Credentials fetched for "+c.userId); if (!nologin && ! AuthenticationService.authenticatedCreds(c)) // this will cause the browser to redirect to login service, // terminating this application @@ -227,7 +225,7 @@ export class OARAuthenticationService extends AuthenticationService { }), catchError((e) => { console.error("Credentials not available (status = "+e.status+")"); - if (e.status && e.status == 401) + if (e.status && e.status == 401) return this.handleUnauthenticated(!nologin, returnURL); return this.handleFetchError(e); }) @@ -235,7 +233,7 @@ export class OARAuthenticationService extends AuthenticationService { } /** - * fetch credentials for the currently logged in user from a given endpoint. This will not + * fetch credentials for the currently logged in user from a given endpoint. This will not * attempt to log the user in. */ public fetchCredentialsFrom(endpoint: string): Observable { @@ -245,7 +243,6 @@ export class OARAuthenticationService extends AuthenticationService { let url = endpoint; if (! url.endsWith('/')) url += '/'; url += "auth/_tokeninfo"; - console.log("Authentication request url: ", url); return this.httpcli.get(url).pipe( map(messageToCredentials) @@ -253,16 +250,16 @@ export class OARAuthenticationService extends AuthenticationService { } /** - * handle the case where the remote service indicates that the user is not logged in. This + * handle the case where the remote service indicates that the user is not logged in. This * implementation will redirect the browser to the login site (via loginUser()) if requested; * otherwise, it returns anonymous credentials. - * @param authReturnURL if provided, the login process will be initiated; if this requires - * browser redirection, this parameter will be interpreeted as the + * @param authReturnURL if provided, the login process will be initiated; if this requires + * browser redirection, this parameter will be interpreeted as the * URL to return to after completing the process. - * @return Observable + * @return Observable */ handleUnauthenticated(dologin: boolean, authReturnURL?: string) : Observable { - if (dologin) + if (dologin) // this will cause the browser to redirect to login service, // terminating this application if (this.loginUser(authReturnURL)) @@ -271,10 +268,10 @@ export class OARAuthenticationService extends AuthenticationService { } /** - * Handle the possible errors while fetching Credentials. The error could be + * Handle the possible errors while fetching Credentials. The error could be * directly from the HTTP call (and is, thus, an HttpErrorResponse) or an error * occuring while processing the response (making it a simple Error). This - * implementation will interpret the type of error to report a helpful error message + * implementation will interpret the type of error to report a helpful error message * to the consult, and then reraise the error. * @param error The error object. * @returns an Observable returned by throwError() @@ -282,9 +279,9 @@ export class OARAuthenticationService extends AuthenticationService { handleFetchError(error: any) { if (error.status != undefined) { let message = null; - if (error.status == 0) + if (error.status == 0) message = "Authentication Client/Communiction Error: " + error.error - else if (error.status >= 400 && error.status < 500) + else if (error.status >= 400 && error.status < 500) message = "Authentication service reports: " + error.message + "; incorrect service endpoint configuration?" else if (error.status > 500) @@ -293,21 +290,21 @@ export class OARAuthenticationService extends AuthenticationService { message = "Unexpected Authentication service response: " + error.message console.error(message); } - else + else console.error("Failure processing Authentication service response: "+error); return throwError(error); } - + /** - * redirect the browser to the authentication service, instructing it to return back to - * the current landing page. - * + * redirect the browser to the authentication service, instructing it to return back to + * the current landing page. + * * @param returnURL the URL that the login service should redirect to after a successful login * to return the browser to this application. If not provided, the value - * of window.location.href will be used. - * @return boolean True if the implementation issued a browser redirect; False, otherwise. - * This allows the caller to halt operations if redirection is imminent. + * of window.location.href will be used. + * @return boolean True if the implementation issued a browser redirect; False, otherwise. + * This allows the caller to halt operations if redirection is imminent. */ public loginUser(returnURL?: string): boolean { let loginURL = this.getLoginURL(returnURL); @@ -318,11 +315,11 @@ export class OARAuthenticationService extends AuthenticationService { } /** - * An AuthService intended for development and testing purposes which simulates interaction - * with a authorization service. + * An AuthService intended for development and testing purposes which simulates interaction + * with a authorization service. * - * This implementation does not contact any remote service. Instead, this service is provided - * with the user identity information representing the authenticated user at construction time. + * This implementation does not contact any remote service. Instead, this service is provided + * with the user identity information representing the authenticated user at construction time. */ @Injectable({ providedIn: 'root' @@ -347,22 +344,22 @@ export class MockAuthenticationService extends AuthenticationService { } /** - * fetch valid credentials. + * fetch valid credentials. * * This implementation just returns the fake credentials set at construction time * - * @param nologin if false (default) and the user is not logged in, an attempt to log the - * user in will be made. This may cause the browser to be redirected - * to a login service. If this value is true, redirection will not occur; instead, - * the anonymous identity will be set as the credentials. + * @param nologin if false (default) and the user is not logged in, an attempt to log the + * user in will be made. This may cause the browser to be redirected + * to a login service. If this value is true, redirection will not occur; instead, + * the anonymous identity will be set as the credentials. */ public fetchCredentials(nologin: boolean = false): Observable { return of(this._fakeCred); } - + /** - * redirect the browser to the authentication service, instructing it to return back to - * this application after the login process is complete. + * redirect the browser to the authentication service, instructing it to return back to + * this application after the login process is complete. * * This implementation does nothing. */ diff --git a/libs/oarng/src/lib/wizard/pushingsidebar.component.ts b/libs/oarng/src/lib/wizard/pushingsidebar.component.ts index 53c1a21..37dab24 100644 --- a/libs/oarng/src/lib/wizard/pushingsidebar.component.ts +++ b/libs/oarng/src/lib/wizard/pushingsidebar.component.ts @@ -3,7 +3,7 @@ import { state, style, trigger, transition, animate } from '@angular/animations' /** * A Panel that includes a sidebar that can be opened and closed. When it is opened, - * it pushes content out of the way (as opposed to covering over it). + * it pushes content out of the way (as opposed to covering over it). */ @Component({ selector: 'oar-pushing-sidebar', @@ -44,12 +44,11 @@ export class PushingSidebarComponent { constructor(private chref: ChangeDetectorRef) { } /** - * toggle whether the sidebar is visible. When this is called, a change in + * toggle whether the sidebar is visible. When this is called, a change in * in the visiblity of the sidebar will be animated (either opened or closed). */ toggleSbarView() { this._sbarvisible = ! this._sbarvisible; - console.log("toggling view: " + this._sbarvisible); this.chref.detectChanges(); } diff --git a/libs/oarng/src/lib/wizard/slideoutcol.component.ts b/libs/oarng/src/lib/wizard/slideoutcol.component.ts index ad890c8..2acc728 100644 --- a/libs/oarng/src/lib/wizard/slideoutcol.component.ts +++ b/libs/oarng/src/lib/wizard/slideoutcol.component.ts @@ -3,7 +3,7 @@ import { state, style, trigger, transition, animate } from '@angular/animations' /** * A Panel that includes a sidebar that can be opened and closed. When it is opened, - * it pushes content out of the way (as opposed to covering over it). + * it pushes content out of the way (as opposed to covering over it). */ @Component({ selector: 'oar-slideout-col', @@ -54,12 +54,11 @@ A 201 response MAY contain an ETag response header field indicating the current ]}) export class SlideoutColumnComponent { private _helpvisible : boolean = false; - + constructor(private chref: ChangeDetectorRef) { } - + toggleHelpView() { this._helpvisible = ! this._helpvisible; - console.log("toggling view: " + this._helpvisible); this.chref.detectChanges(); }