From 353de981a462e1753288d225ec4644a44a62d2bc Mon Sep 17 00:00:00 2001 From: Jamie Date: Fri, 10 Feb 2023 09:11:25 +0000 Subject: [PATCH] fix(wizard): :bug: Stop access to the wizard when you have already setup ombi (#4866) --- src/Ombi/.vscode/settings.json | 3 ++- src/Ombi/ClientApp/src/app/login/login.component.ts | 2 ++ .../ClientApp/src/app/services/status.service.ts | 8 ++++++-- .../src/app/wizard/welcome/welcome.component.ts | 12 ++++++++++-- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Ombi/.vscode/settings.json b/src/Ombi/.vscode/settings.json index 6274dd334..96d5fba50 100644 --- a/src/Ombi/.vscode/settings.json +++ b/src/Ombi/.vscode/settings.json @@ -24,7 +24,8 @@ "details", "requests", "sonarr", - "plex" + "plex", + "wizard" ], "rpc.enabled": true } diff --git a/src/Ombi/ClientApp/src/app/login/login.component.ts b/src/Ombi/ClientApp/src/app/login/login.component.ts index 9c243da4f..1f24ed88b 100644 --- a/src/Ombi/ClientApp/src/app/login/login.component.ts +++ b/src/Ombi/ClientApp/src/app/login/login.component.ts @@ -90,6 +90,8 @@ export class LoginComponent implements OnDestroy, OnInit { if (authService.loggedIn()) { this.loadStores(); + + this.router.navigate(["/"]); } } diff --git a/src/Ombi/ClientApp/src/app/services/status.service.ts b/src/Ombi/ClientApp/src/app/services/status.service.ts index dd252e607..0fbded8cc 100644 --- a/src/Ombi/ClientApp/src/app/services/status.service.ts +++ b/src/Ombi/ClientApp/src/app/services/status.service.ts @@ -11,7 +11,11 @@ export class StatusService extends ServiceHelpers { constructor(http: HttpClient, @Inject(APP_BASE_HREF) href:string) { super(http, "/api/v1/status/", href); } - public getWizardStatus(): Observable { - return this.http.get(`${this.url}Wizard/`, {headers: this.headers}); + public getWizardStatus(): Observable { + return this.http.get(`${this.url}Wizard/`, {headers: this.headers}); } } + +export interface WizardResult { + result: boolean; +} diff --git a/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts b/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts index 2ab230980..e8a905530 100644 --- a/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts +++ b/src/Ombi/ClientApp/src/app/wizard/welcome/welcome.component.ts @@ -1,5 +1,5 @@ import { Component, OnInit, ViewChild } from "@angular/core"; -import { IdentityService, NotificationService, SettingsService } from "../../services"; +import { IdentityService, NotificationService, SettingsService, StatusService } from "../../services"; import { CustomizationFacade } from "../../state/customization/customization.facade"; import { ICreateWizardUser } from "../../interfaces"; @@ -7,6 +7,7 @@ import { IOmbiConfigModel } from "../models/OmbiConfigModel"; import { MatStepper } from'@angular/material/stepper'; import { Router } from "@angular/router"; import { WizardService } from "../services/wizard.service"; +import { Observable, take } from "rxjs"; @Component({ templateUrl: "./welcome.component.html", @@ -20,9 +21,16 @@ export class WelcomeComponent implements OnInit { constructor(private router: Router, private identityService: IdentityService, private notificationService: NotificationService, private WizardService: WizardService, - private settingsService: SettingsService, private customizationFacade: CustomizationFacade) { } + private settingsService: SettingsService, private customizationFacade: CustomizationFacade, + private status: StatusService) { } public ngOnInit(): void { + this.status.getWizardStatus().pipe(take(1)) + .subscribe(x => { + if (x.result) { + this.router.navigate(["login"]); + } + }); this.localUser = { password:"", username:"",