Fix loop when cannot fetch roles (#41901)

This commit is contained in:
Alexander Zobnin 2021-11-19 12:23:03 +03:00 committed by GitHub
parent c5241731de
commit d66158a042
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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) => {