Login: allow basic users to reset password when LDAP or Auth Proxy is enabled (#52331)

This commit is contained in:
Krzysztof Dąbrowski
2022-08-08 07:12:39 +02:00
committed by GitHub
parent 62b4dbf52f
commit 2dab7ad890
7 changed files with 51 additions and 43 deletions

View File

@@ -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>;

View File

@@ -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;