From ff76ebb3f09515090424362cc814718f5eb2cfe2 Mon Sep 17 00:00:00 2001 From: xsanm Date: Thu, 28 Nov 2024 14:08:43 +0100 Subject: [PATCH] [web] remove password change feature Summary: This was discussed in [ENG-8070](https://linear.app/comm/issue/ENG-8070/regenerate-backup-on-every-password-change#comment-c64a499b) Only the primary device should be able to change the password. Perhaps there was some alternative to keep this for a while and disable this after the user migrated to Signed Device Lists (v2), but this is not easy and probably there is no need to complicate just to keep this screen for a ~month and then remove. Test Plan: No option to change password in account settings screen Reviewers: ashoat, varun Reviewed By: ashoat Subscribers: tomek Differential Revision: https://phab.comm.dev/D14062 --- web/settings/account-settings.css | 14 -- web/settings/account-settings.react.js | 27 --- web/settings/password-change-modal.css | 38 ---- web/settings/password-change-modal.js | 296 ------------------------- 4 files changed, 375 deletions(-) delete mode 100644 web/settings/password-change-modal.css delete mode 100644 web/settings/password-change-modal.js diff --git a/web/settings/account-settings.css b/web/settings/account-settings.css index 47adf83f49..28daa7bbf9 100644 --- a/web/settings/account-settings.css +++ b/web/settings/account-settings.css @@ -56,20 +56,6 @@ line-height: var(--line-height-text); } -.passwordContainer { - display: flex; -} - -.password { - align-items: center; - padding-right: 16px; -} - -.editPasswordLink { - color: var(--text-background-tertiary-default); - cursor: pointer; -} - .preferencesContainer { padding-top: 24px; } diff --git a/web/settings/account-settings.react.js b/web/settings/account-settings.react.js index 28abe82250..c9539f9b5e 100644 --- a/web/settings/account-settings.react.js +++ b/web/settings/account-settings.react.js @@ -12,7 +12,6 @@ import { import { useModalContext } from 'lib/components/modal-provider.react.js'; import SWMansionIcon from 'lib/components/swmansion-icon.react.js'; import { useStringForUser } from 'lib/hooks/ens-cache.js'; -import { accountHasPassword } from 'lib/shared/account-utils.js'; import { dmOperationSpecificationTypes, type OutboundDMOperationSpecification, @@ -32,7 +31,6 @@ import { useDispatchActionPromise } from 'lib/utils/redux-promise-utils.js'; import css from './account-settings.css'; import AppearanceChangeModal from './appearance-change-modal.react.js'; import BackupTestRestoreModal from './backup-test-restore-modal.react.js'; -import PasswordChangeModal from './password-change-modal.js'; import BlockListModal from './relationship/block-list-modal.react.js'; import FriendListModal from './relationship/friend-list-modal.react.js'; import TunnelbrokerMessagesScreen from './tunnelbroker-message-list.react.js'; @@ -80,11 +78,6 @@ function AccountSettings(): React.Node { })(); }, []); - const showPasswordChangeModal = React.useCallback( - () => pushModal(), - [pushModal], - ); - const openFriendList = React.useCallback( () => pushModal(), [pushModal], @@ -95,10 +88,6 @@ function AccountSettings(): React.Node { [pushModal], ); - const isAccountWithPassword = useSelector(state => - accountHasPassword(state.currentUserInfo), - ); - const currentUserInfo = useSelector(state => state.currentUserInfo); const stringForUser = useStringForUser(currentUserInfo); @@ -181,21 +170,6 @@ function AccountSettings(): React.Node { return null; } - let changePasswordSection; - if (isAccountWithPassword) { - changePasswordSection = ( -
  • - Password - - ****** - - - - -
  • - ); - } - let experimentalLogOutSection; if (isDev) { experimentalLogOutSection = ( @@ -337,7 +311,6 @@ function AccountSettings(): React.Node { {experimentalLogOutSection} - {changePasswordSection}
  • Friend List - ); - - return ( - -
    -
    -

    - {'Logged in as '} - {this.props.stringForUser} -

    - - - -
    - {errorMsg} -
    -
    - ); - } - - newPasswordInputRef = (newPasswordInput: ?HTMLInputElement) => { - this.newPasswordInput = newPasswordInput; - }; - - currentPasswordInputRef = (currentPasswordInput: ?HTMLInputElement) => { - this.currentPasswordInput = currentPasswordInput; - }; - - onChangeNewPassword = (event: SyntheticEvent) => { - const target = event.target; - invariant(target instanceof HTMLInputElement, 'target not input'); - this.setState({ newPassword: target.value }); - }; - - onChangeConfirmNewPassword = (event: SyntheticEvent) => { - const target = event.target; - invariant(target instanceof HTMLInputElement, 'target not input'); - this.setState({ confirmNewPassword: target.value }); - }; - - onChangeCurrentPassword = (event: SyntheticEvent) => { - const target = event.target; - invariant(target instanceof HTMLInputElement, 'target not input'); - this.setState({ currentPassword: target.value }); - }; - - onSubmit = (event: SyntheticEvent) => { - event.preventDefault(); - - if (this.state.newPassword === '') { - this.setState( - { - newPassword: '', - confirmNewPassword: '', - errorMessage: 'empty password', - }, - () => { - invariant(this.newPasswordInput, 'newPasswordInput ref unset'); - this.newPasswordInput.focus(); - }, - ); - } else if (this.state.newPassword !== this.state.confirmNewPassword) { - this.setState( - { - newPassword: '', - confirmNewPassword: '', - errorMessage: 'passwords don’t match', - }, - () => { - invariant(this.newPasswordInput, 'newPasswordInput ref unset'); - this.newPasswordInput.focus(); - }, - ); - return; - } - - if (usingCommServicesAccessToken) { - void this.props.dispatchActionPromise( - changeIdentityUserPasswordActionTypes, - this.changeUserSettingsAction(), - ); - } else { - void this.props.dispatchActionPromise( - changeKeyserverUserPasswordActionTypes, - this.changeUserSettingsAction(), - ); - } - }; - - async changeUserSettingsAction(): Promise { - try { - if (usingCommServicesAccessToken) { - await this.props.changeIdentityUserPassword( - this.state.currentPassword, - this.state.newPassword, - ); - } else { - await this.props.changeKeyserverUserPassword({ - updatedFields: { - password: this.state.newPassword, - }, - currentPassword: this.state.currentPassword, - }); - } - this.props.popModal(); - } catch (e) { - const messageForException = getMessageForException(e); - if ( - messageForException === 'invalid_credentials' || - messageForException === 'login_failed' - ) { - this.setState( - { - currentPassword: '', - errorMessage: 'wrong current password', - }, - () => { - invariant( - this.currentPasswordInput, - 'currentPasswordInput ref unset', - ); - this.currentPasswordInput.focus(); - }, - ); - } else { - this.setState( - { - newPassword: '', - confirmNewPassword: '', - currentPassword: '', - errorMessage: 'unknown error', - }, - () => { - invariant(this.newPasswordInput, 'newPasswordInput ref unset'); - this.newPasswordInput.focus(); - }, - ); - } - throw e; - } - } -} - -const changeUserPasswordLoadingStatusSelector = usingCommServicesAccessToken - ? createLoadingStatusSelector(changeIdentityUserPasswordActionTypes) - : createLoadingStatusSelector(changeKeyserverUserPasswordActionTypes); -const ConnectedPasswordChangeModal: React.ComponentType<{}> = React.memo<{}>( - function ConnectedPasswordChangeModal(): React.Node { - const inputDisabled = useSelector( - state => changeUserPasswordLoadingStatusSelector(state) === 'loading', - ); - const callChangeKeyserverUserPassword = useLegacyAshoatKeyserverCall( - changeKeyserverUserPassword, - ); - const callChangeIdentityUserPassword = useChangeIdentityUserPassword(); - const dispatchActionPromise = useDispatchActionPromise(); - - const modalContext = useModalContext(); - - const currentUserInfo = useSelector(state => state.currentUserInfo); - const stringForUser = useStringForUser(currentUserInfo); - - return ( - - ); - }, -); - -export default ConnectedPasswordChangeModal;