Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3350498
D11912.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11912.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D11912: [lib] add reserved username workflow to identity login actions
Attached
Detach File
Event Timeline
Log In to Comment