Avoid showing provider form if proivder is set up (#1128)

This commit is contained in:
Oscar Hinton 2021-08-18 11:35:43 +02:00 committed by GitHub
parent cdab6e7091
commit 4e134823df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 3 deletions

View File

@ -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(['/']);
}
});
}