mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Login: allow basic users to reset password when LDAP or Auth Proxy is enabled (#52331)
This commit is contained in:
committed by
GitHub
parent
62b4dbf52f
commit
2dab7ad890
@@ -16,11 +16,11 @@ export interface Props {
|
||||
}
|
||||
|
||||
export const ChangePasswordForm: FC<Props> = ({ user, onChangePassword, isSaving }) => {
|
||||
const { ldapEnabled, authProxyEnabled, disableLoginForm } = config;
|
||||
const { disableLoginForm } = config;
|
||||
const authSource = user.authLabels?.length && user.authLabels[0];
|
||||
|
||||
if (ldapEnabled || authProxyEnabled) {
|
||||
return <p>You cannot change password when LDAP or auth proxy authentication is enabled.</p>;
|
||||
if (authSource === 'LDAP' || authSource === 'Auth Proxy') {
|
||||
return <p>You cannot change password when signed in with LDAP or auth proxy.</p>;
|
||||
}
|
||||
if (authSource && disableLoginForm) {
|
||||
return <p>Password cannot be changed here.</p>;
|
||||
|
||||
@@ -84,19 +84,19 @@ describe('ChangePasswordPage', () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
it('should cannot change password form if ldap or authProxy enabled', async () => {
|
||||
config.ldapEnabled = true;
|
||||
const { rerender } = await getTestContext();
|
||||
expect(
|
||||
screen.getByText('You cannot change password when LDAP or auth proxy authentication is enabled.')
|
||||
).toBeInTheDocument();
|
||||
config.ldapEnabled = false;
|
||||
config.authProxyEnabled = true;
|
||||
rerender(<ChangePasswordPage {...defaultProps} />);
|
||||
expect(
|
||||
screen.getByText('You cannot change password when LDAP or auth proxy authentication is enabled.')
|
||||
).toBeInTheDocument();
|
||||
config.authProxyEnabled = false;
|
||||
it('should cannot change password form if user signed in with LDAP', async () => {
|
||||
await getTestContext({
|
||||
user: { ...defaultProps.user!, authLabels: ['LDAP'] },
|
||||
});
|
||||
|
||||
expect(screen.getByText('You cannot change password when signed in with LDAP or auth proxy.')).toBeInTheDocument();
|
||||
});
|
||||
it('should cannot change password form if user signed in with auth proxy', async () => {
|
||||
await getTestContext({
|
||||
user: { ...defaultProps.user!, authLabels: ['Auth Proxy'] },
|
||||
});
|
||||
|
||||
expect(screen.getByText('You cannot change password when signed in with LDAP or auth proxy.')).toBeInTheDocument();
|
||||
});
|
||||
it('should show cannot change password if disableLoginForm is true and auth', async () => {
|
||||
config.disableLoginForm = true;
|
||||
|
||||
Reference in New Issue
Block a user