Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3359110
D11083.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
D11083.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
@@ -429,24 +429,17 @@
success: 'IDENTITY_REGISTER_SUCCESS',
failed: 'IDENTITY_REGISTER_FAILED',
});
-function useIdentityRegister(): (
+function useIdentityPasswordRegister(): (
username: string,
password: string,
) => Promise<IdentityAuthResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
- return React.useCallback(
- (username, password) => {
- if (!identityClient) {
- throw new Error('Identity service client is not initialized');
- }
- if (!identityClient.registerPasswordUser) {
- throw new Error('Register user method unimplemented');
- }
- return identityClient.registerPasswordUser(username, password);
- },
- [identityClient],
- );
+ invariant(identityClient, 'Identity client should be set');
+ if (!identityClient.registerPasswordUser) {
+ throw new Error('Register user method unimplemented');
+ }
+ return identityClient.registerPasswordUser;
}
const identityGenerateNonceActionTypes = Object.freeze({
@@ -854,7 +847,7 @@
keyserverAuthActionTypes,
useKeyserverAuth,
identityRegisterActionTypes,
- useIdentityRegister,
+ useIdentityPasswordRegister,
identityGenerateNonceActionTypes,
useIdentityGenerateNonce,
};
diff --git a/native/account/registration/registration-server-call.js b/native/account/registration/registration-server-call.js
--- a/native/account/registration/registration-server-call.js
+++ b/native/account/registration/registration-server-call.js
@@ -6,7 +6,7 @@
import {
keyserverRegisterActionTypes,
keyserverRegister,
- useIdentityRegister,
+ useIdentityPasswordRegister,
identityRegisterActionTypes,
} from 'lib/actions/user-actions.js';
import type { LogInStartingPayload } from 'lib/types/account-types.js';
@@ -68,13 +68,13 @@
const dispatchActionPromise = useDispatchActionPromise();
const callKeyserverRegister = useLegacyAshoatKeyserverCall(keyserverRegister);
- const callIdentityRegister = useIdentityRegister();
+ const callIdentityPasswordRegister = useIdentityPasswordRegister();
const identityRegisterUsernameAccount = React.useCallback(
async (accountSelection: UsernameAccountSelection) => {
const identityRegisterPromise = (async () => {
try {
- const result = await callIdentityRegister(
+ const result = await callIdentityPasswordRegister(
accountSelection.username,
accountSelection.password,
);
@@ -114,7 +114,7 @@
);
await identityRegisterPromise;
},
- [callIdentityRegister, dispatchActionPromise],
+ [callIdentityPasswordRegister, dispatchActionPromise],
);
const keyserverRegisterUsernameAccount = React.useCallback(
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Nov 25, 7:12 AM (20 h, 20 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2578900
Default Alt Text
D11083.diff (2 KB)
Attached To
Mode
D11083: [lib][native] simplify and rename identity password registration hook
Attached
Detach File
Event Timeline
Log In to Comment