diff --git a/app/containers/ChangePasswordRequired.tsx b/app/containers/ChangePasswordRequired.tsx index 60407ef63d..6a58458e3b 100644 --- a/app/containers/ChangePasswordRequired.tsx +++ b/app/containers/ChangePasswordRequired.tsx @@ -2,7 +2,7 @@ import React, { useState } from 'react'; import { StyleSheet, Text, View } from 'react-native'; import { useDispatch } from 'react-redux'; -import { logout } from '../actions/login'; +import { logout, setUser } from '../actions/login'; import I18n from '../i18n'; import { useSetting } from '../lib/hooks/useSetting'; import { showErrorAlert } from '../lib/methods/helpers'; @@ -28,6 +28,7 @@ export const ChangePasswordRequired = () => { setLoading(true); try { await Services.setUserPassword(password); + dispatch(setUser({ requirePasswordChange: false })); hideActionSheet(); } catch (error: any) { showErrorAlert(error?.reason || error?.message, I18n.t('Oops')); diff --git a/app/i18n/locales/en.json b/app/i18n/locales/en.json index 306c8f9ab9..731eab669a 100644 --- a/app/i18n/locales/en.json +++ b/app/i18n/locales/en.json @@ -836,5 +836,10 @@ "Your_invite_link_will_never_expire": "Your invite link will never expire.", "Your_password_is": "Your password is", "Your_push_was_sent_to_s_devices": "Your push was sent to {{s}} devices", - "Your_workspace": "Your workspace" + "Your_workspace": "Your workspace", + "You_need_to_change_your_password": "You need to change your password", + "To_continue_using_RocketChat": "To continue using the mobile app, you need to change your password.", + "Change_password": "Change password", + "Please_Enter_your_new_password": "Please enter your new password", + "Confirm_your_password": "Confirm your password" } \ No newline at end of file diff --git a/app/sagas/login.js b/app/sagas/login.js index b30218516f..117d3730c7 100644 --- a/app/sagas/login.js +++ b/app/sagas/login.js @@ -290,16 +290,22 @@ const handleLogout = function* handleLogout({ forcedByServer, message }) { }; const handleSetUser = function* handleSetUser({ user }) { - if ('avatarETag' in user) { + if ('avatarETag' in user || 'requirePasswordChange' in user) { const userId = yield select(state => state.login.user.id); const serversDB = database.servers; const userCollections = serversDB.get('users'); yield serversDB.write(async () => { try { const userRecord = await userCollections.find(userId); - await userRecord.update(record => { - record.avatarETag = user.avatarETag; - }); + if ('avatarETag' in user) { + await userRecord.update(record => { + record.avatarETag = user.avatarETag; + }); + } else if ('requirePasswordChange' in user) { + await userRecord.update(record => { + record.requirePasswordChange = user.requirePasswordChange; + }); + } } catch { // } diff --git a/app/views/RoomsListView/index.tsx b/app/views/RoomsListView/index.tsx index 994a56dcf1..d88b4116dd 100644 --- a/app/views/RoomsListView/index.tsx +++ b/app/views/RoomsListView/index.tsx @@ -316,6 +316,9 @@ class RoomsListView extends React.Component