Fix loop when cannot fetch roles (#41901) (#41945)

(cherry picked from commit d66158a042)

Co-authored-by: Alexander Zobnin <alexanderzobnin@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2021-11-19 14:05:43 +03:00
committed by GitHub
co-authored by Alexander Zobnin
parent 0838146d16
commit 81043a763e
@@ -60,11 +60,16 @@ export const fetchUserRoles = async (userId: number, orgId?: number): Promise<Ro
if (orgId) {
userRolesUrl += `?targetOrgId=${orgId}`;
}
const roles = await getBackendSrv().get(userRolesUrl);
if (!roles || !roles.length) {
try {
const roles = await getBackendSrv().get(userRolesUrl);
if (!roles || !roles.length) {
return [];
}
return roles;
} catch (error) {
error.isHandled = true;
return [];
}
return roles;
};
export const updateUserRoles = (roleUids: string[], userId: number, orgId?: number) => {