cleanup login function

This commit is contained in:
Blair Vanderlugt 2021-04-24 10:15:47 -07:00
parent 7103f15236
commit c1a1a83d85
2 changed files with 7 additions and 33 deletions

View File

@ -25,7 +25,7 @@ export class AuthService {
this.mutableKeyStore = new MutablePgpKeyStore()
}
async init(): void {
async init(): Promise<void> {
this.mutableKeyStore.loadKeyring();
// TODO setting these together shoulds be atomic
if (sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'))) {
@ -97,36 +97,6 @@ export class AuthService {
xhr.send();
}
login(): boolean {
// TODO check if we have privatekey
// Send us to home if we have a private key
// talk to meta somehow
// in the error interceptor if 401/403 handle it
// if 200 go /home
if (!this.getPrivateKey()) {
return false;
}
return true;
// if (this.sessionToken !== undefined) {
// try {
// //this.getWithToken();
// return true;
// } catch (e) {
// this.loggingService.sendErrorLevelMessage('Login token failed', this, {error: e});
// }
// } else {
// try {
// // this.getChallenge();
// return true
// } catch (e) {
// this.loggingService.sendErrorLevelMessage('Login challenge failed', this, {error: e});
// }
// }
//return false;
}
async loginResponse(o): Promise<any> {
return new Promise(async(resolve, reject) => {
try {

View File

@ -46,8 +46,12 @@ export class AuthComponent implements OnInit {
}
login(): void {
const loginStatus = this.authService.login();
if (loginStatus) {
// TODO check if we have privatekey
// Send us to home if we have a private key
// talk to meta somehow
// in the error interceptor if 401/403 handle it
// if 200 go /home
if (this.authService.getPrivateKey()) {
this.router.navigate(['/home']);
}
}