Removed self-hosted restriction from Login with Device (#5441)

* Removed self-hosted restriction from Login with Device.

* Updated showPasswordless client-side flag to true for self-hosted.

* Linting

* Linting
This commit is contained in:
Todd Martin 2023-06-01 12:38:10 -04:00 committed by GitHub
parent cf63a5680c
commit 23bd5de37c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 14 deletions

View File

@ -98,7 +98,7 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
async ngOnInit() { async ngOnInit() {
await super.ngOnInit(); await super.ngOnInit();
await this.checkSelfHosted(); await this.getLoginWithDevice(this.loggedEmail);
this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => { this.broadcasterService.subscribe(BroadcasterSubscriptionId, async (message: any) => {
this.ngZone.run(() => { this.ngZone.run(() => {
switch (message.command) { switch (message.command) {
@ -151,7 +151,7 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
// eslint-disable-next-line rxjs/no-async-subscribe // eslint-disable-next-line rxjs/no-async-subscribe
childComponent.onSaved.pipe(takeUntil(this.componentDestroyed$)).subscribe(async () => { childComponent.onSaved.pipe(takeUntil(this.componentDestroyed$)).subscribe(async () => {
modal.close(); modal.close();
await this.checkSelfHosted(); await this.getLoginWithDevice(this.loggedEmail);
}); });
} }
@ -188,10 +188,4 @@ export class LoginComponent extends BaseLoginComponent implements OnDestroy {
const email = this.loggedEmail; const email = this.loggedEmail;
document.getElementById(email == null || email === "" ? "email" : "masterPassword").focus(); document.getElementById(email == null || email === "" ? "email" : "masterPassword").focus();
} }
private async checkSelfHosted() {
this.selfHosted = this.environmentService.isSelfHosted();
await this.getLoginWithDevice(this.loggedEmail);
}
} }

View File

@ -8,6 +8,6 @@
}, },
"flags": { "flags": {
"secretsManager": false, "secretsManager": false,
"showPasswordless": false "showPasswordless": true
} }
} }

View File

@ -35,7 +35,6 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
onSuccessfulLoginNavigate: () => Promise<any>; onSuccessfulLoginNavigate: () => Promise<any>;
onSuccessfulLoginTwoFactorNavigate: () => Promise<any>; onSuccessfulLoginTwoFactorNavigate: () => Promise<any>;
onSuccessfulLoginForceResetNavigate: () => Promise<any>; onSuccessfulLoginForceResetNavigate: () => Promise<any>;
selfHosted = false;
showLoginWithDevice: boolean; showLoginWithDevice: boolean;
validatedEmail = false; validatedEmail = false;
paramEmailSet = false; paramEmailSet = false;
@ -73,7 +72,6 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
protected loginService: LoginService protected loginService: LoginService
) { ) {
super(environmentService, i18nService, platformUtilsService); super(environmentService, i18nService, platformUtilsService);
this.selfHosted = platformUtilsService.isSelfHost();
} }
get selfHostedDomain() { get selfHostedDomain() {
@ -295,9 +293,10 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit
async getLoginWithDevice(email: string) { async getLoginWithDevice(email: string) {
try { try {
const deviceIdentifier = await this.appIdService.getAppId(); const deviceIdentifier = await this.appIdService.getAppId();
const res = await this.devicesApiService.getKnownDevice(email, deviceIdentifier); this.showLoginWithDevice = await this.devicesApiService.getKnownDevice(
//ensure the application is not self-hosted email,
this.showLoginWithDevice = res && !this.selfHosted; deviceIdentifier
);
} catch (e) { } catch (e) {
this.showLoginWithDevice = false; this.showLoginWithDevice = false;
} }