1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-17 08:43:33 +00:00

Wrap sso login with pre-validation check (#160)

* Wrap sso login with pre-validation check

* Add form promise for SSO preValidate

* Removed boolean variable, .catch()
This commit is contained in:
Chad Scharf
2020-09-08 10:36:22 -04:00
committed by GitHub
parent 0bff8bcd56
commit fa2b8e834b
3 changed files with 46 additions and 2 deletions

View File

@@ -23,6 +23,7 @@ export class SsoComponent {
loggingIn = false;
formPromise: Promise<AuthResult>;
initiateSsoFormPromise: Promise<any>;
onSuccessfulLogin: () => Promise<any>;
onSuccessfulLoginNavigate: () => Promise<any>;
onSuccessfulLoginTwoFactorNavigate: () => Promise<any>;
@@ -67,8 +68,20 @@ export class SsoComponent {
}
async submit(returnUri?: string, includeUserIdentifier?: boolean) {
const authorizeUrl = await this.buildAuthorizeUrl(returnUri, includeUserIdentifier);
this.platformUtilsService.launchUri(authorizeUrl, { sameWindow: true });
this.initiateSsoFormPromise = this.preValidate();
if (await this.initiateSsoFormPromise) {
const authorizeUrl = await this.buildAuthorizeUrl(returnUri, includeUserIdentifier);
this.platformUtilsService.launchUri(authorizeUrl, { sameWindow: true });
}
}
async preValidate(): Promise<boolean> {
if (this.identifier == null || this.identifier === '') {
this.platformUtilsService.showToast('error', this.i18nService.t('ssoValidationFailed'),
this.i18nService.t('ssoIdentifierRequired'));
return false;
}
return await this.apiService.preValidateSso(this.identifier);
}
protected async buildAuthorizeUrl(returnUri?: string, includeUserIdentifier?: boolean): Promise<string> {