Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F33027522
D12468.1768398132.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D12468.1768398132.diff
View Options
diff --git a/web/settings/password-change-modal.js b/web/settings/password-change-modal.js
--- a/web/settings/password-change-modal.js
+++ b/web/settings/password-change-modal.js
@@ -6,16 +6,20 @@
import {
changeKeyserverUserPasswordActionTypes,
changeKeyserverUserPassword,
+ useChangeIdentityUserPassword,
+ changeIdentityUserPasswordActionTypes,
} from 'lib/actions/user-actions.js';
import { useModalContext } from 'lib/components/modal-provider.react.js';
import { useStringForUser } from 'lib/hooks/ens-cache.js';
import { useLegacyAshoatKeyserverCall } from 'lib/keyserver-conn/legacy-keyserver-call.js';
import { createLoadingStatusSelector } from 'lib/selectors/loading-selectors.js';
import { type PasswordUpdate } from 'lib/types/user-types.js';
+import { getMessageForException } from 'lib/utils/errors.js';
import {
useDispatchActionPromise,
type DispatchActionPromise,
} from 'lib/utils/redux-promise-utils.js';
+import { usingCommServicesAccessToken } from 'lib/utils/services-utils.js';
import css from './password-change-modal.css';
import Button from '../components/button.react.js';
@@ -29,6 +33,10 @@
+changeKeyserverUserPassword: (
passwordUpdate: PasswordUpdate,
) => Promise<void>,
+ +changeIdentityUserPassword: (
+ oldPassword: string,
+ newPassword: string,
+ ) => Promise<void>,
+popModal: () => void,
+stringForUser: ?string,
};
@@ -186,23 +194,41 @@
return;
}
- void this.props.dispatchActionPromise(
- changeKeyserverUserPasswordActionTypes,
- this.changeUserSettingsAction(),
- );
+ if (usingCommServicesAccessToken) {
+ void this.props.dispatchActionPromise(
+ changeIdentityUserPasswordActionTypes,
+ this.changeUserSettingsAction(),
+ );
+ } else {
+ void this.props.dispatchActionPromise(
+ changeKeyserverUserPasswordActionTypes,
+ this.changeUserSettingsAction(),
+ );
+ }
};
async changeUserSettingsAction(): Promise<void> {
try {
- await this.props.changeKeyserverUserPassword({
- updatedFields: {
- password: this.state.newPassword,
- },
- currentPassword: this.state.currentPassword,
- });
+ 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) {
- if (e.message === 'invalid_credentials') {
+ const messageForException = getMessageForException(e);
+ if (
+ messageForException === 'invalid_credentials' ||
+ messageForException === 'login_failed'
+ ) {
this.setState(
{
currentPassword: '',
@@ -235,17 +261,18 @@
}
}
-const changeKeyserverUserPasswordLoadingStatusSelector =
- createLoadingStatusSelector(changeKeyserverUserPasswordActionTypes);
+const changeUserPasswordLoadingStatusSelector = usingCommServicesAccessToken
+ ? createLoadingStatusSelector(changeIdentityUserPasswordActionTypes)
+ : createLoadingStatusSelector(changeKeyserverUserPasswordActionTypes);
const ConnectedPasswordChangeModal: React.ComponentType<{}> = React.memo<{}>(
function ConnectedPasswordChangeModal(): React.Node {
const inputDisabled = useSelector(
- state =>
- changeKeyserverUserPasswordLoadingStatusSelector(state) === 'loading',
+ state => changeUserPasswordLoadingStatusSelector(state) === 'loading',
);
const callChangeKeyserverUserPassword = useLegacyAshoatKeyserverCall(
changeKeyserverUserPassword,
);
+ const callChangeIdentityUserPassword = useChangeIdentityUserPassword();
const dispatchActionPromise = useDispatchActionPromise();
const modalContext = useModalContext();
@@ -257,6 +284,7 @@
<PasswordChangeModal
inputDisabled={inputDisabled}
changeKeyserverUserPassword={callChangeKeyserverUserPassword}
+ changeIdentityUserPassword={callChangeIdentityUserPassword}
dispatchActionPromise={dispatchActionPromise}
popModal={modalContext.popModal}
stringForUser={stringForUser}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jan 14, 1:42 PM (4 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5932255
Default Alt Text
D12468.1768398132.diff (4 KB)
Attached To
Mode
D12468: [web] allow password users registered with identity to change their password from web
Attached
Detach File
Event Timeline
Log In to Comment