Format files using linter.
This commit is contained in:
parent
df395b7b61
commit
0866c4c22f
@ -9,7 +9,7 @@ export class HttpConfigInterceptor implements HttpInterceptor {
|
||||
|
||||
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
// const token: string = sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'));
|
||||
const token: string = AuthService.getSessionToken()
|
||||
const token: string = AuthService.getSessionToken();
|
||||
|
||||
if (token) {
|
||||
request = request.clone({ headers: request.headers.set('Authorization', 'Bearer ' + token) });
|
||||
|
@ -14,13 +14,6 @@ import { BehaviorSubject, Observable } from 'rxjs';
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class AuthService {
|
||||
mutableKeyStore: MutableKeyStore;
|
||||
trustedUsers: Array<Staff> = [];
|
||||
private trustedUsersList: BehaviorSubject<Array<Staff>> = new BehaviorSubject<Array<Staff>>(
|
||||
this.trustedUsers
|
||||
);
|
||||
trustedUsersSubject: Observable<Array<Staff>> = this.trustedUsersList.asObservable();
|
||||
|
||||
constructor(
|
||||
private httpClient: HttpClient,
|
||||
private loggingService: LoggingService,
|
||||
@ -28,6 +21,16 @@ export class AuthService {
|
||||
) {
|
||||
this.mutableKeyStore = new MutablePgpKeyStore();
|
||||
}
|
||||
mutableKeyStore: MutableKeyStore;
|
||||
trustedUsers: Array<Staff> = [];
|
||||
private trustedUsersList: BehaviorSubject<Array<Staff>> = new BehaviorSubject<Array<Staff>>(
|
||||
this.trustedUsers
|
||||
);
|
||||
trustedUsersSubject: Observable<Array<Staff>> = this.trustedUsersList.asObservable();
|
||||
|
||||
public static getSessionToken(): string {
|
||||
return sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'));
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
await this.mutableKeyStore.loadKeyring();
|
||||
@ -36,10 +39,6 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
public static getSessionToken(): string {
|
||||
return sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'));
|
||||
}
|
||||
|
||||
setSessionToken(token): void {
|
||||
sessionStorage.setItem(btoa('CICADA_SESSION_TOKEN'), token);
|
||||
}
|
||||
@ -59,9 +58,9 @@ export class AuthService {
|
||||
};
|
||||
return fetch(environment.cicMetaUrl, options).then((response) => {
|
||||
if (!response.ok) {
|
||||
this.loggingService.sendErrorLevelMessage('failed to get with auth token.',
|
||||
this,
|
||||
{ error: "" });
|
||||
this.loggingService.sendErrorLevelMessage('failed to get with auth token.', this, {
|
||||
error: '',
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -79,12 +78,11 @@ export class AuthService {
|
||||
const options = {
|
||||
headers,
|
||||
};
|
||||
return fetch(environment.cicMetaUrl, options)
|
||||
return fetch(environment.cicMetaUrl, options);
|
||||
}
|
||||
|
||||
getChallenge(): Promise<any> {
|
||||
return fetch(environment.cicMetaUrl)
|
||||
.then(response => {
|
||||
return fetch(environment.cicMetaUrl).then((response) => {
|
||||
if (response.status === 401) {
|
||||
const authHeader: string = response.headers.get('WWW-Authenticate');
|
||||
return hobaParseChallengeHeader(authHeader);
|
||||
@ -105,29 +103,25 @@ export class AuthService {
|
||||
this.mutableKeyStore
|
||||
);
|
||||
|
||||
const tokenResponse = await this.sendSignedChallenge(r)
|
||||
.then(response => {
|
||||
const token = response.headers.get('Token')
|
||||
const tokenResponse = await this.sendSignedChallenge(r).then((response) => {
|
||||
const token = response.headers.get('Token');
|
||||
if (token) {
|
||||
return token
|
||||
return token;
|
||||
}
|
||||
if (response.status === 401) {
|
||||
let e = new HttpError("You are not authorized to use this system", response.status)
|
||||
throw e
|
||||
throw new HttpError('You are not authorized to use this system', response.status);
|
||||
}
|
||||
if (!response.ok) {
|
||||
let e = new HttpError("Unknown error from authentication server", response.status)
|
||||
throw e
|
||||
throw new HttpError('Unknown error from authentication server', response.status);
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
if (tokenResponse) {
|
||||
this.setSessionToken(tokenResponse);
|
||||
this.setState('Click button to log in');
|
||||
return true
|
||||
return true;
|
||||
}
|
||||
return false
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
loginView(): void {
|
||||
|
@ -5,10 +5,9 @@ import { TokenRegistry } from '@app/_eth';
|
||||
import { HttpGetter } from '@app/_helpers';
|
||||
import { Web3Service } from '@app/_services/web3.service';
|
||||
|
||||
|
||||
// export interface RegistryCollection {
|
||||
// cicRegistry: CICRegistry,
|
||||
// tokenRegistry: TokenRegistry
|
||||
// cicRegistry: CICRegistry;
|
||||
// tokenRegistry: TokenRegistry;
|
||||
// }
|
||||
|
||||
@Injectable({
|
||||
@ -30,8 +29,7 @@ export class RegistryService {
|
||||
['../../assets/js/block-sync/data']
|
||||
);
|
||||
RegistryService.registry.declaratorHelper.addTrust(environment.trustedDeclaratorAddress);
|
||||
await RegistryService.registry.load()
|
||||
|
||||
await RegistryService.registry.load();
|
||||
}
|
||||
return RegistryService.registry;
|
||||
}
|
||||
@ -39,16 +37,17 @@ export class RegistryService {
|
||||
public static async getTokenRegistry(): Promise<TokenRegistry> {
|
||||
if (!RegistryService.tokenRegistry) {
|
||||
// then initial it
|
||||
const registry = await RegistryService.getRegistry()
|
||||
const tokenRegistryAddress = await RegistryService.registry.getContractAddressByName('TokenRegistry')
|
||||
const registry = await RegistryService.getRegistry();
|
||||
const tokenRegistryAddress = await RegistryService.registry.getContractAddressByName(
|
||||
'TokenRegistry'
|
||||
);
|
||||
RegistryService.tokenRegistry = new TokenRegistry(tokenRegistryAddress);
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(RegistryService.tokenRegistry)
|
||||
})
|
||||
resolve(RegistryService.tokenRegistry);
|
||||
});
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
resolve(RegistryService.tokenRegistry);
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -14,7 +14,9 @@ export class TokenService {
|
||||
tokenRegistry: TokenRegistry;
|
||||
onload: (status: boolean) => void;
|
||||
tokens: Array<Token> = [];
|
||||
private tokensList: BehaviorSubject<Array<Token>> = new BehaviorSubject<Array<Token>>(this.tokens);
|
||||
private tokensList: BehaviorSubject<Array<Token>> = new BehaviorSubject<Array<Token>>(
|
||||
this.tokens
|
||||
);
|
||||
tokensSubject: Observable<Array<Token>> = this.tokensList.asObservable();
|
||||
|
||||
constructor(private httpClient: HttpClient) {}
|
||||
|
@ -22,7 +22,7 @@ export class AuthComponent implements OnInit {
|
||||
private authService: AuthService,
|
||||
private formBuilder: FormBuilder,
|
||||
private router: Router,
|
||||
private errorDialogService: ErrorDialogService,
|
||||
private errorDialogService: ErrorDialogService
|
||||
) {}
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
@ -49,7 +49,7 @@ export class AuthComponent implements OnInit {
|
||||
|
||||
async login(): Promise<void> {
|
||||
try {
|
||||
const loginResult = await this.authService.login()
|
||||
const loginResult = await this.authService.login();
|
||||
if (loginResult) {
|
||||
this.router.navigate(['/home']);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user