Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3149432
D10454.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
D10454.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
@@ -30,6 +30,7 @@
UpdateUserAvatarResponse,
} from '../types/avatar-types.js';
import type { RawEntryInfo, CalendarQuery } from '../types/entry-types.js';
+import type { IdentityRegisterResult } from '../types/identity-service-types.js';
import type {
RawMessageInfo,
MessageTruncationStatuses,
@@ -372,6 +373,31 @@
);
}
+const identityRegisterActionTypes = Object.freeze({
+ started: 'IDENTITY_REGISTER_STARTED',
+ success: 'IDENTITY_REGISTER_SUCCESS',
+ failed: 'IDENTITY_REGISTER_FAILED',
+});
+function useIdentityRegister(): (
+ username: string,
+ password: string,
+) => Promise<IdentityRegisterResult> {
+ 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.registerUser) {
+ throw new Error('Register user method unimplemented');
+ }
+ return identityClient.registerUser(username, password);
+ },
+ [identityClient],
+ );
+}
+
function mergeUserInfos(
...userInfoArrays: Array<$ReadOnlyArray<UserInfo>>
): UserInfo[] {
@@ -723,4 +749,6 @@
useDeleteIdentityAccount,
keyserverAuthActionTypes,
useKeyserverAuth,
+ identityRegisterActionTypes,
+ useIdentityRegister,
};
diff --git a/lib/types/identity-service-types.js b/lib/types/identity-service-types.js
--- a/lib/types/identity-service-types.js
+++ b/lib/types/identity-service-types.js
@@ -22,6 +22,10 @@
export interface IdentityServiceClient {
+deleteUser: () => Promise<void>;
+getKeyserverKeys: string => Promise<?OutboundKeyInfoResponse>;
+ +registerUser?: (
+ username: string,
+ password: string,
+ ) => Promise<IdentityRegisterResult>;
}
export type IdentityServiceAuthLayer = {
@@ -43,3 +47,9 @@
+username?: ?string,
+walletAddress?: ?string,
};
+
+export type IdentityRegisterResult = {
+ +userID: string,
+ +accessToken: string,
+ +username: string,
+};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 5, 1:56 PM (17 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2426140
Default Alt Text
D10454.diff (2 KB)
Attached To
Mode
D10454: [lib] add identity register action
Attached
Detach File
Event Timeline
Log In to Comment