Lint code.

This commit is contained in:
Spencer Ofwiti 2021-06-07 18:49:15 +03:00
parent 159cedc86e
commit 8e96b070a5
3 changed files with 36 additions and 18 deletions

View File

@ -102,8 +102,11 @@ export class AuthService {
await this.loginResponse(o, password); await this.loginResponse(o, password);
return true; return true;
} catch (error) { } catch (error) {
this.loggingService.sendErrorLevelMessage(`Login challenge failed: Error ${error.status} - ${error.statusText}`, this.loggingService.sendErrorLevelMessage(
this, {error}); `Login challenge failed: Error ${error.status} - ${error.statusText}`,
this,
{ error }
);
} }
return false; return false;
} }
@ -114,8 +117,11 @@ export class AuthService {
this.getWithToken(); this.getWithToken();
return true; return true;
} catch (error) { } catch (error) {
this.loggingService.sendErrorLevelMessage(`Login token failed: Error ${error.status} - ${error.statusText}`, this.loggingService.sendErrorLevelMessage(
this, {error}); `Login token failed: Error ${error.status} - ${error.statusText}`,
this,
{ error }
);
} }
} }
return false; return false;
@ -162,9 +168,11 @@ export class AuthService {
if (!isValidKeyCheck) { if (!isValidKeyCheck) {
throw Error('The private key is invalid'); throw Error('The private key is invalid');
} }
const isEncryptedKeyCheck = await this.mutableKeyStore.isEncryptedPrivateKey(privateKeyArmored); const isEncryptedKeyCheck = await this.mutableKeyStore.isEncryptedPrivateKey(
privateKeyArmored
);
if (!isEncryptedKeyCheck) { if (!isEncryptedKeyCheck) {
throw Error('The private key doesn\'t have a password!'); throw Error('The private key does not have a password!');
} }
const key = await this.mutableKeyStore.importPrivateKey(privateKeyArmored); const key = await this.mutableKeyStore.importPrivateKey(privateKeyArmored);
localStorage.setItem(btoa('CICADA_PRIVATE_KEY'), privateKeyArmored); localStorage.setItem(btoa('CICADA_PRIVATE_KEY'), privateKeyArmored);

View File

@ -23,7 +23,7 @@ export class AuthComponent implements OnInit {
private authService: AuthService, private authService: AuthService,
private formBuilder: FormBuilder, private formBuilder: FormBuilder,
private router: Router, private router: Router,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef
) {} ) {}
async ngOnInit(): Promise<void> { async ngOnInit(): Promise<void> {
@ -44,8 +44,12 @@ export class AuthComponent implements OnInit {
} }
} }
get keyFormStub(): any { return this.keyForm.controls; } get keyFormStub(): any {
get passwordFormStub(): any { return this.passwordForm.controls; } return this.keyForm.controls;
}
get passwordFormStub(): any {
return this.passwordForm.controls;
}
async onSubmit(): Promise<void> { async onSubmit(): Promise<void> {
this.keyFormSubmitted = true; this.keyFormSubmitted = true;
@ -66,10 +70,14 @@ export class AuthComponent implements OnInit {
async onPasswordInput(): Promise<void> { async onPasswordInput(): Promise<void> {
this.passwordFormSubmitted = true; this.passwordFormSubmitted = true;
if (this.passwordForm.invalid) { return; } if (this.passwordForm.invalid) {
return;
}
this.passwordFormLoading = true; this.passwordFormLoading = true;
const passwordLogin = await this.authService.passwordLogin(this.passwordFormStub.password.value); const passwordLogin = await this.authService.passwordLogin(
this.passwordFormStub.password.value
);
if (passwordLogin) { if (passwordLogin) {
this.loginView(); this.loginView();
} }
@ -95,7 +103,9 @@ export class AuthComponent implements OnInit {
passwordInput(): void { passwordInput(): void {
this.authService.sessionToken = undefined; this.authService.sessionToken = undefined;
this.switchWindows(false, true, false); this.switchWindows(false, true, false);
this.setPasswordState('Enter Password to log in with PGP key ' + this.authService.mutableKeyStore.getPrivateKeyId()); this.setPasswordState(
'Enter Password to log in with PGP key ' + this.authService.mutableKeyStore.getPrivateKeyId()
);
} }
loginView(): void { loginView(): void {