Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2838214
D12325.id41001.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D12325.id41001.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
@@ -355,7 +355,9 @@
// used to reset state (eg. Redux, SQLite) to a logged-out state. The state
// reset only occurs when a success action is dispatched, so we always dispatch
// a success.
-function useDeleteDiscardedIdentityAccount(): () => Promise<LogOutResult> {
+function useDeleteDiscardedIdentityAccount(): (
+ password: ?string,
+) => Promise<LogOutResult> {
const client = React.useContext(IdentityClientContext);
const identityClient = client?.identityClient;
@@ -364,35 +366,44 @@
state => state.commServicesAccessToken,
);
- return React.useCallback(async () => {
- invariant(
- usingCommServicesAccessToken,
- 'deleteDiscardedIdentityAccount can only be called when ' +
- 'usingCommServicesAccessToken',
- );
- if (!identityClient) {
- throw new Error('Identity service client is not initialized');
- }
- if (!identityClient.deleteWalletUser) {
- throw new Error('Delete wallet user method unimplemented');
- }
- try {
- await Promise.race([
- identityClient.deleteWalletUser(),
- (async () => {
- await sleep(500);
- throw new Error('identity delete_wallet_user took more than 500ms');
- })(),
- ]);
- } catch {}
- return {
- currentUserInfo: null,
- preRequestUserState: {
- ...preRequestUserState,
- commServicesAccessToken,
- },
- };
- }, [commServicesAccessToken, identityClient, preRequestUserState]);
+ return React.useCallback(
+ async password => {
+ invariant(
+ usingCommServicesAccessToken,
+ 'deleteDiscardedIdentityAccount can only be called when ' +
+ 'usingCommServicesAccessToken',
+ );
+ if (!identityClient) {
+ throw new Error('Identity service client is not initialized');
+ }
+ if (
+ !identityClient.deleteWalletUser ||
+ !identityClient.deletePasswordUser
+ ) {
+ throw new Error('Delete user method unimplemented');
+ }
+ const deleteUserCall = password
+ ? identityClient.deletePasswordUser(password)
+ : identityClient.deleteWalletUser();
+ try {
+ await Promise.race([
+ deleteUserCall,
+ (async () => {
+ await sleep(500);
+ throw new Error('identity delete user call took more than 500ms');
+ })(),
+ ]);
+ } catch {}
+ return {
+ currentUserInfo: null,
+ preRequestUserState: {
+ ...preRequestUserState,
+ commServicesAccessToken,
+ },
+ };
+ },
+ [commServicesAccessToken, identityClient, preRequestUserState],
+ );
}
const legacyKeyserverRegisterActionTypes = Object.freeze({
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
@@ -465,7 +465,9 @@
);
const discardIdentityAccountPromise = (async () => {
try {
- const deletionResult = await deleteDiscardedIdentityAccount();
+ const deletionResult = await deleteDiscardedIdentityAccount(
+ credentialsToSave?.password,
+ );
if (messageForException === 'client_version_unsupported') {
Alert.alert(
appOutOfDateAlertDetails.title,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 29, 9:20 PM (21 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2202701
Default Alt Text
D12325.id41001.diff (3 KB)
Attached To
Mode
D12325: [lib][native] update useDeleteDiscardedIdentityAccount to call deletePasswordUser when appropriate
Attached
Detach File
Event Timeline
Log In to Comment