import { css } from '@emotion/css'; import React, { FC } from 'react'; import { Button, Field, Form, HorizontalGroup, LinkButton } from '@grafana/ui'; import config from 'app/core/config'; import { UserDTO } from 'app/types'; import { PasswordField } from '../../core/components/PasswordField/PasswordField'; import { ChangePasswordFields } from './types'; export interface Props { user: UserDTO; isSaving: boolean; onChangePassword: (payload: ChangePasswordFields) => void; } export const ChangePasswordForm: FC = ({ user, onChangePassword, isSaving }) => { const { ldapEnabled, authProxyEnabled, disableLoginForm } = config; const authSource = user.authLabels?.length && user.authLabels[0]; if (ldapEnabled || authProxyEnabled) { return

You cannot change password when LDAP or auth proxy authentication is enabled.

; } if (authSource && disableLoginForm) { return

Password cannot be changed here.

; } return (
{({ register, errors, getValues }) => { return ( <> v === getValues().confirmNew || 'Passwords must match', old: (v) => v !== getValues().oldPassword || `New password can't be the same as the old one.`, }, })} /> v === getValues().newPassword || 'Passwords must match', })} /> Cancel ); }}
); };