mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
LDAP debug page: deduplicate errors (#19168)
This commit is contained in:
parent
5ef40b259d
commit
6b2e95a1f2
@ -38,6 +38,7 @@ export function loadLdapState(): ThunkResult<void> {
|
|||||||
const connectionInfo = await getLdapState();
|
const connectionInfo = await getLdapState();
|
||||||
dispatch(ldapConnectionInfoLoadedAction(connectionInfo));
|
dispatch(ldapConnectionInfoLoadedAction(connectionInfo));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.isHandled = true;
|
||||||
const ldapError = {
|
const ldapError = {
|
||||||
title: error.data.message,
|
title: error.data.message,
|
||||||
body: error.data.error,
|
body: error.data.error,
|
||||||
@ -63,6 +64,7 @@ export function loadUserMapping(username: string): ThunkResult<void> {
|
|||||||
const userInfo = await getUserInfo(username);
|
const userInfo = await getUserInfo(username);
|
||||||
dispatch(userMappingInfoLoadedAction(userInfo));
|
dispatch(userMappingInfoLoadedAction(userInfo));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.isHandled = true;
|
||||||
const userError = {
|
const userError = {
|
||||||
title: error.data.message,
|
title: error.data.message,
|
||||||
body: error.data.error,
|
body: error.data.error,
|
||||||
@ -106,6 +108,7 @@ export function loadLdapUserInfo(userId: number): ThunkResult<void> {
|
|||||||
dispatch(loadUserSessions(userId));
|
dispatch(loadUserSessions(userId));
|
||||||
dispatch(loadUserMapping(user.login));
|
dispatch(loadUserMapping(user.login));
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
error.isHandled = true;
|
||||||
const userError = {
|
const userError = {
|
||||||
title: error.data.message,
|
title: error.data.message,
|
||||||
body: error.data.error,
|
body: error.data.error,
|
||||||
|
@ -47,18 +47,14 @@ export const syncLdapUser = async (userId: number) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const getUserInfo = async (username: string): Promise<LdapUser> => {
|
export const getUserInfo = async (username: string): Promise<LdapUser> => {
|
||||||
try {
|
const response = await getBackendSrv().get(`/api/admin/ldap/${username}`);
|
||||||
const response = await getBackendSrv().get(`/api/admin/ldap/${username}`);
|
const { name, surname, email, login, isGrafanaAdmin, isDisabled, roles, teams } = response;
|
||||||
const { name, surname, email, login, isGrafanaAdmin, isDisabled, roles, teams } = response;
|
return {
|
||||||
return {
|
info: { name, surname, email, login },
|
||||||
info: { name, surname, email, login },
|
permissions: { isGrafanaAdmin, isDisabled },
|
||||||
permissions: { isGrafanaAdmin, isDisabled },
|
roles,
|
||||||
roles,
|
teams,
|
||||||
teams,
|
};
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getUser = async (id: number): Promise<User> => {
|
export const getUser = async (id: number): Promise<User> => {
|
||||||
|
Loading…
Reference in New Issue
Block a user