diff --git a/web/settings/account-settings.css b/web/settings/account-settings.css --- 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 --- a/web/settings/account-settings.react.js +++ b/web/settings/account-settings.react.js @@ -12,7 +12,6 @@ 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 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 @@ })(); }, []); - const showPasswordChangeModal = React.useCallback( - () => pushModal(), - [pushModal], - ); - const openFriendList = React.useCallback( () => pushModal(), [pushModal], @@ -95,10 +88,6 @@ [pushModal], ); - const isAccountWithPassword = useSelector(state => - accountHasPassword(state.currentUserInfo), - ); - const currentUserInfo = useSelector(state => state.currentUserInfo); const stringForUser = useStringForUser(currentUserInfo); @@ -181,21 +170,6 @@ return null; } - let changePasswordSection; - if (isAccountWithPassword) { - changePasswordSection = ( -
  • - Password - - ****** - - - - -
  • - ); - } - let experimentalLogOutSection; if (isDev) { experimentalLogOutSection = ( @@ -337,7 +311,6 @@ {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;