From 312165799170953cf2425303ce22b7f1dbb5f2be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Klocek?= Date: Tue, 3 Dec 2024 12:25:19 +0100 Subject: [PATCH] [identity] Update V1 logout to handle new flow users Summary: Addresss [[ https://linear.app/comm/issue/ENG-9696/update-v1-logout-rpc-to-skip-reorder-in-new-login-flow | ENG-9696 ]]. We want V1 logout to still work for new flows, but with two things: - Don't update device list server side - Inform the client that it should use new flows (it already handles the use_new_flow response) Depends on D14075 Test Plan: - Register a user - V1 logout - OK - Log in again and sign the device list (e.g. perform QR login) - V1 logout again - The `use_new_flow` is returned and a message is displayed on client Reviewers: kamil, varun Reviewed By: kamil Subscribers: ashoat, tomek Differential Revision: https://phab.comm.dev/D14076 --- .../src/grpc_services/authenticated.rs | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs index d05822b7aa..b9fb6991aa 100644 --- a/services/identity/src/grpc_services/authenticated.rs +++ b/services/identity/src/grpc_services/authenticated.rs @@ -374,7 +374,21 @@ impl IdentityClientService for AuthenticatedService { ) -> Result, tonic::Status> { let (user_id, device_id) = get_user_and_device_id(&request)?; - self.db_client.remove_device(&user_id, &device_id).await?; + let is_new_flow_user = self + .db_client + .get_user_login_flow(&user_id) + .await? + .is_signed_device_list_flow(); + + // don't update device list for new flow users + if is_new_flow_user { + self + .db_client + .remove_device_data(&user_id, &device_id) + .await?; + } else { + self.db_client.remove_device(&user_id, &device_id).await?; + } self .db_client @@ -422,6 +436,13 @@ impl IdentityClientService for AuthenticatedService { let blob_client = self.authenticated_blob_client().await?; spawn_delete_devices_services_data_task(&blob_client, [device_id].into()); + // for new flow users we should inform it that should use new flow + if is_new_flow_user { + return Err(tonic::Status::failed_precondition( + tonic_status_messages::USE_NEW_FLOW, + )); + } + let response = Empty {}; Ok(Response::new(response)) }