Page MenuHomePhabricator

D11912.diff
No OneTemporary

D11912.diff

diff --git a/lib/actions/user-actions.js b/lib/actions/user-actions.js
--- a/lib/actions/user-actions.js
+++ b/lib/actions/user-actions.js
@@ -68,6 +68,7 @@
} from '../types/user-types.js';
import { authoritativeKeyserverID } from '../utils/authoritative-keyserver.js';
import { getConfig } from '../utils/config.js';
+import { getMessageForException } from '../utils/errors.js';
import { useSelector } from '../utils/redux-utils.js';
import { usingCommServicesAccessToken } from '../utils/services-utils.js';
import sleep from '../utils/sleep.js';
@@ -617,6 +618,7 @@
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
const preRequestUserState = useSelector(state => state.currentUserInfo);
+ const callClaimUsername = useClaimUsername();
return React.useCallback(
(username, password) => {
@@ -624,17 +626,36 @@
throw new Error('Identity service client is not initialized');
}
return (async () => {
- const result = await identityClient.logInPasswordUser(
- username,
- password,
- );
+ let result;
+ try {
+ result = await identityClient.logInPasswordUser(username, password);
+ } catch (e) {
+ const { registerReservedPasswordUser } = identityClient;
+ if (
+ !registerReservedPasswordUser ||
+ getMessageForException(e) !==
+ 'need keyserver message to claim username'
+ ) {
+ throw e;
+ }
+ const { message, signature } = await callClaimUsername({
+ username,
+ password,
+ });
+ result = await registerReservedPasswordUser(
+ username,
+ password,
+ message,
+ signature,
+ );
+ }
return {
...result,
preRequestUserState,
};
})();
},
- [identityClient, preRequestUserState],
+ [identityClient, preRequestUserState, callClaimUsername],
);
}
function useIdentityWalletLogIn(): (

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 23, 10:51 PM (20 h, 14 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2572686
Default Alt Text
D11912.diff (2 KB)

Event Timeline