mirror of
https://github.com/bitwarden/browser
synced 2025-12-21 02:33:46 +00:00
Add auto submit on identifier query parameter (#9803)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
import { FormControl, FormGroup, Validators } from "@angular/forms";
|
||||||
import { ActivatedRoute, Router } from "@angular/router";
|
import { ActivatedRoute, Router } from "@angular/router";
|
||||||
|
import { firstValueFrom } from "rxjs";
|
||||||
import { first } from "rxjs/operators";
|
import { first } from "rxjs/operators";
|
||||||
|
|
||||||
import { SsoComponent as BaseSsoComponent } from "@bitwarden/angular/auth/components/sso.component";
|
import { SsoComponent as BaseSsoComponent } from "@bitwarden/angular/auth/components/sso.component";
|
||||||
@@ -92,6 +93,7 @@ export class SsoComponent extends BaseSsoComponent {
|
|||||||
if (qParams.identifier != null) {
|
if (qParams.identifier != null) {
|
||||||
// SSO Org Identifier in query params takes precedence over claimed domains
|
// SSO Org Identifier in query params takes precedence over claimed domains
|
||||||
this.identifierFormControl.setValue(qParams.identifier);
|
this.identifierFormControl.setValue(qParams.identifier);
|
||||||
|
await this.submit();
|
||||||
} else {
|
} else {
|
||||||
// Note: this flow is written for web but both browser and desktop
|
// Note: this flow is written for web but both browser and desktop
|
||||||
// redirect here on SSO button click.
|
// redirect here on SSO button click.
|
||||||
@@ -145,11 +147,21 @@ export class SsoComponent extends BaseSsoComponent {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const autoSubmit = (await firstValueFrom(this.route.queryParams)).identifier != null;
|
||||||
|
|
||||||
this.identifier = this.identifierFormControl.value;
|
this.identifier = this.identifierFormControl.value;
|
||||||
await this.ssoLoginService.setOrganizationSsoIdentifier(this.identifier);
|
await this.ssoLoginService.setOrganizationSsoIdentifier(this.identifier);
|
||||||
if (this.clientId === "browser") {
|
if (this.clientId === "browser") {
|
||||||
document.cookie = `ssoHandOffMessage=${this.i18nService.t("ssoHandOff")};SameSite=strict`;
|
document.cookie = `ssoHandOffMessage=${this.i18nService.t("ssoHandOff")};SameSite=strict`;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
await Object.getPrototypeOf(this).submit.call(this);
|
await Object.getPrototypeOf(this).submit.call(this);
|
||||||
|
} catch (error) {
|
||||||
|
if (autoSubmit) {
|
||||||
|
await this.router.navigate(["/login"]);
|
||||||
|
} else {
|
||||||
|
this.validationService.showError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user