Skip to content

Commit 5416b90

Browse files
fix: change required password not working (#6684)
1 parent b76942d commit 5416b90

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

app/lib/services/restApi.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -629,6 +629,16 @@ export const saveRoomSettings = (
629629
// RC 0.55.0
630630
sdk.methodCallWrapper('saveRoomSettings', rid, params);
631631

632+
export const setPassword = (newPassword: string) => {
633+
const serverVersion = reduxStore.getState().server.version;
634+
635+
if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '7.10.0')) {
636+
return saveUserProfile({ newPassword } as IProfileParams);
637+
}
638+
639+
return sdk.methodCall('setUserPassword', newPassword);
640+
};
641+
632642
export const saveUserProfile = (
633643
data: IProfileParams | Pick<IProfileParams, 'username' | 'name'>,
634644
customFields?: { [key: string | number]: string }

app/views/ChangePasswordView/index.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@ import { NativeStackNavigationProp } from '@react-navigation/native-stack';
77
import { useDispatch } from 'react-redux';
88
import { sha256 } from 'js-sha256';
99

10-
import { IProfileParams } from '../../definitions/IProfile';
1110
import { twoFactor } from '../../lib/services/twoFactor';
1211
import { ProfileStackParamList } from '../../stacks/types';
1312
import { ControlledFormTextInput } from '../../containers/TextInput';
1413
import { useAppSelector } from '../../lib/hooks/useAppSelector';
1514
import { isAndroid, showErrorAlert } from '../../lib/methods/helpers';
1615
import { useTheme } from '../../theme';
1716
import { TwoFactorMethods } from '../../definitions/ITotp';
18-
import { saveUserProfile } from '../../lib/services/restApi';
17+
import { saveUserProfile, setPassword } from '../../lib/services/restApi';
1918
import { events, logEvent } from '../../lib/methods/helpers/log';
2019
import { setUser } from '../../actions/login';
2120
import { LISTENER } from '../../containers/Toast';
@@ -105,11 +104,11 @@ const ChangePasswordView = ({ navigation }: IChangePasswordViewProps) => {
105104
};
106105

107106
const changePassword = async () => {
108-
const { newPassword, currentPassword } = inputValues;
107+
const { newPassword } = inputValues;
109108

110109
try {
111110
setValue('saving', true);
112-
await saveUserProfile({ newPassword, currentPassword: sha256(currentPassword) } as IProfileParams);
111+
await setPassword(newPassword);
113112
dispatch(setUser({ requirePasswordChange: false }));
114113
navigation.goBack();
115114
} catch (error: any) {

0 commit comments

Comments
 (0)