messages
This commit is contained in:
parent
a69213dab2
commit
09c45aa2e5
@ -59,7 +59,9 @@ export class ErrorInterceptor implements HttpInterceptor {
|
||||
this.router.navigateByUrl('/auth').then();
|
||||
break;
|
||||
case 403: // forbidden
|
||||
alert('Access to resource is not allowed!');
|
||||
this.errorDialogService.openDialog(
|
||||
{ message: 'Access to resource is not allowed (Error 403)'})
|
||||
//alert('Access to resource is not allowed!');
|
||||
break;
|
||||
}
|
||||
// Return an observable with a user-facing error message.
|
||||
|
@ -48,8 +48,9 @@ export class AuthService {
|
||||
}
|
||||
|
||||
getWithToken(): Promise<boolean> {
|
||||
const sessionToken = this.getSessionToken()
|
||||
const headers = {
|
||||
Authorization: 'Bearer ' + this.getSessionToken,
|
||||
Authorization: 'Bearer ' + sessionToken,
|
||||
'Content-Type': 'application/json;charset=utf-8',
|
||||
'x-cic-automerge': 'none',
|
||||
};
|
||||
@ -93,36 +94,36 @@ export class AuthService {
|
||||
async login(): Promise<boolean> {
|
||||
if (this.getSessionToken()) {
|
||||
sessionStorage.removeItem(btoa('CICADA_SESSION_TOKEN'));
|
||||
} else {
|
||||
const o = await this.getChallenge();
|
||||
}
|
||||
const o = await this.getChallenge();
|
||||
|
||||
const r = await signChallenge(
|
||||
o.challenge,
|
||||
o.realm,
|
||||
environment.cicMetaUrl,
|
||||
this.mutableKeyStore
|
||||
);
|
||||
const r = await signChallenge(
|
||||
o.challenge,
|
||||
o.realm,
|
||||
environment.cicMetaUrl,
|
||||
this.mutableKeyStore
|
||||
);
|
||||
|
||||
const tokenResponse = await this.sendSignedChallenge(r).then((response) => {
|
||||
const tokenResponse = await this.sendSignedChallenge(r)
|
||||
.then((response) => {
|
||||
const token = response.headers.get('Token');
|
||||
if (token) {
|
||||
return token;
|
||||
return token;
|
||||
}
|
||||
if (response.status === 401) {
|
||||
throw new HttpError('You are not authorized to use this system', response.status);
|
||||
throw new HttpError('You are not authorized to use this system', response.status);
|
||||
}
|
||||
if (!response.ok) {
|
||||
throw new HttpError('Unknown error from authentication server', response.status);
|
||||
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 false;
|
||||
if (tokenResponse) {
|
||||
this.setSessionToken(tokenResponse);
|
||||
//this.setState('Click button to log in');
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
loginView(): void {
|
||||
|
@ -58,7 +58,7 @@ export class AuthComponent implements OnInit {
|
||||
}
|
||||
} catch (HttpError) {
|
||||
this.errorDialogService.openDialog({
|
||||
message: HttpError.message,
|
||||
message: "Failed to login please try again.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user