libs/testing/basic-auth.testing.ts
Methods |
|
constructor(basicAuthSrvc: BasicAuthService)
|
||||||
Defined in libs/testing/basic-auth.testing.ts:6
|
||||||
Parameters :
|
Public doBasicAuth | ||||||
doBasicAuth(url: string)
|
||||||
Defined in libs/testing/basic-auth.testing.ts:12
|
||||||
Parameters :
Returns :
Observable<boolean>
|
import { Injectable } from '@angular/core';
import { BasicAuthInformer, BasicAuthService, BasicAuthServiceMaintainer } from '@helgoland/auth';
import { Observable, Observer } from 'rxjs';
@Injectable()
export class BasicAuthInformerImplService implements BasicAuthInformer {
constructor(
private basicAuthSrvc: BasicAuthService
) { }
public doBasicAuth(url: string): Observable<boolean> {
return new Observable<boolean>((observer: Observer<boolean>) => {
const username = prompt('Basic Auth username for ' + url);
const password = prompt('Basic Auth password for ' + url);
this.basicAuthSrvc.auth(username, password, url).subscribe(
token => {
observer.next(true);
observer.complete();
},
error => {
observer.next(false);
observer.complete();
}
);
});
}
}
export const BasicAuthTestingProviders = [
BasicAuthService,
BasicAuthServiceMaintainer,
{
provide: BasicAuthInformer,
useClass: BasicAuthInformerImplService
}
];