From 4e134823dfc76f54551a6f875f075a5332ff0f46 Mon Sep 17 00:00:00 2001 From: Oscar Hinton Date: Wed, 18 Aug 2021 11:35:43 +0200 Subject: [PATCH] Avoid showing provider form if proivder is set up (#1128) --- .../src/app/providers/setup/setup.component.ts | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/bitwarden_license/src/app/providers/setup/setup.component.ts b/bitwarden_license/src/app/providers/setup/setup.component.ts index 853723b2b2..6a4ef1f0c7 100644 --- a/bitwarden_license/src/app/providers/setup/setup.component.ts +++ b/bitwarden_license/src/app/providers/setup/setup.component.ts @@ -58,9 +58,21 @@ export class SetupComponent implements OnInit { }; this.toasterService.popAsync(toast); this.router.navigate(['/']); - } else { - this.providerId = qParams.providerId; - this.token = qParams.token; + return; + } + + this.providerId = qParams.providerId; + this.token = qParams.token; + + // Check if provider exists, redirect if it does + try { + const provider = await this.apiService.getProvider(this.providerId); + if (provider.name != null) { + this.router.navigate(['/providers', provider.id], { replaceUrl: true }); + } + } catch (e) { + this.validationService.showError(e); + this.router.navigate(['/']); } }); }