login button was taking two clicks
This commit is contained in:
parent
61bf336789
commit
df395b7b61
@ -95,39 +95,39 @@ export class AuthService {
|
|||||||
async login(): Promise<boolean> {
|
async login(): Promise<boolean> {
|
||||||
if (AuthService.getSessionToken()) {
|
if (AuthService.getSessionToken()) {
|
||||||
sessionStorage.removeItem(btoa('CICADA_SESSION_TOKEN'));
|
sessionStorage.removeItem(btoa('CICADA_SESSION_TOKEN'));
|
||||||
} else {
|
|
||||||
const o = await this.getChallenge();
|
|
||||||
|
|
||||||
const r = await signChallenge(
|
|
||||||
o.challenge,
|
|
||||||
o.realm,
|
|
||||||
environment.cicMetaUrl,
|
|
||||||
this.mutableKeyStore
|
|
||||||
);
|
|
||||||
|
|
||||||
const tokenResponse = await this.sendSignedChallenge(r)
|
|
||||||
.then(response => {
|
|
||||||
const token = response.headers.get('Token')
|
|
||||||
if (token) {
|
|
||||||
return token
|
|
||||||
}
|
|
||||||
if (response.status === 401) {
|
|
||||||
let e = new HttpError("You are not authorized to use this system", response.status)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
if (!response.ok) {
|
|
||||||
let e = new HttpError("Unknown error from authentication server", response.status)
|
|
||||||
throw e
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
if (tokenResponse) {
|
|
||||||
this.setSessionToken(tokenResponse);
|
|
||||||
this.setState('Click button to log in');
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
|
const o = await this.getChallenge();
|
||||||
|
|
||||||
|
const r = await signChallenge(
|
||||||
|
o.challenge,
|
||||||
|
o.realm,
|
||||||
|
environment.cicMetaUrl,
|
||||||
|
this.mutableKeyStore
|
||||||
|
);
|
||||||
|
|
||||||
|
const tokenResponse = await this.sendSignedChallenge(r)
|
||||||
|
.then(response => {
|
||||||
|
const token = response.headers.get('Token')
|
||||||
|
if (token) {
|
||||||
|
return token
|
||||||
|
}
|
||||||
|
if (response.status === 401) {
|
||||||
|
let e = new HttpError("You are not authorized to use this system", response.status)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
if (!response.ok) {
|
||||||
|
let e = new HttpError("Unknown error from authentication server", response.status)
|
||||||
|
throw e
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (tokenResponse) {
|
||||||
|
this.setSessionToken(tokenResponse);
|
||||||
|
this.setState('Click button to log in');
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
loginView(): void {
|
loginView(): void {
|
||||||
|
Loading…
Reference in New Issue
Block a user