Throw error on no provider

This commit is contained in:
Michael Rogers 2023-07-06 15:25:40 -05:00
parent 06f71412a6
commit 5a6755c3fb
2 changed files with 8 additions and 9 deletions

View File

@ -228,14 +228,13 @@ export default class StatusAPI extends EventEmitter {
async canProvideStatusForCurrentUser() {
const provider = this.#userAPI.getProvider();
if (provider.getStatusRoleForCurrentUser) {
if (!provider) {
return false;
}
const activeStatusRole = await this.#userAPI.getActiveRole();
const canProvideStatus = await this.canProvideStatusForRole(activeStatusRole);
return canProvideStatus;
} else {
return false;
}
}
/**

View File

@ -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