From 5a6755c3fbef5142cef4264bcf5934131b2ba2b5 Mon Sep 17 00:00:00 2001 From: Michael Rogers Date: Thu, 6 Jul 2023 15:25:40 -0500 Subject: [PATCH] Throw error on no provider --- src/api/user/StatusAPI.js | 11 +++++------ src/api/user/UserAPI.js | 6 +++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/api/user/StatusAPI.js b/src/api/user/StatusAPI.js index 6efa428647..30495e280d 100644 --- a/src/api/user/StatusAPI.js +++ b/src/api/user/StatusAPI.js @@ -228,14 +228,13 @@ export default class StatusAPI extends EventEmitter { async canProvideStatusForCurrentUser() { const provider = this.#userAPI.getProvider(); - if (provider.getStatusRoleForCurrentUser) { - const activeStatusRole = await this.#userAPI.getActiveRole(); - const canProvideStatus = await this.canProvideStatusForRole(activeStatusRole); - - return canProvideStatus; - } else { + if (!provider) { return false; } + const activeStatusRole = await this.#userAPI.getActiveRole(); + const canProvideStatus = await this.canProvideStatusForRole(activeStatusRole); + + return canProvideStatus; } /** diff --git a/src/api/user/UserAPI.js b/src/api/user/UserAPI.js index 2dd6e2dd37..fdff67fe4c 100644 --- a/src/api/user/UserAPI.js +++ b/src/api/user/UserAPI.js @@ -92,14 +92,14 @@ class UserAPI extends EventEmitter { * that can be selected by the current user * @memberof module:openmct.UserAPI# * @returns {Array} + * @throws Will throw an error if no user provider is set */ getPossibleRoles() { if (!this.hasProvider()) { - return Promise.resolve(undefined); - } else { - return this._provider.getPossibleRoles(); + this.error(NO_PROVIDER_ERROR); } + return this._provider.getPossibleRoles(); } /** * If a user provider is set, it will return the active role or null