diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs --- a/services/identity/src/client_service.rs +++ b/services/identity/src/client_service.rs @@ -504,40 +504,21 @@ let user_id = if let Some(user_id) = self .client - .get_user_id_from_reserved_usernames_table(&wallet_address) + .get_user_id_from_user_info(wallet_address.clone(), &AuthType::Wallet) .await .map_err(handle_db_error)? { - // It's possible that the user attempting login is already registered - // on Ashoat's keyserver. If they are, we should try to register them if - // they're on a mobile device, otherwise we should send back a gRPC status - // code instructing them to try logging in from a mobile device first. - if platform_metadata.device_type.to_uppercase() != "ANDROID" - && platform_metadata.device_type.to_uppercase() != "IOS" - { - return Err(tonic::Status::permission_denied( - tonic_status_messages::RETRY_FROM_NATIVE, - )); - }; - - let social_proof = - SocialProof::new(message.siwe_message, message.siwe_signature); - self .check_device_id_taken(&flattened_device_key_upload, Some(&user_id)) .await?; self .client - .add_wallet_user_to_users_table( + .add_user_device( + user_id.clone(), flattened_device_key_upload.clone(), - wallet_address.clone(), - social_proof, - Some(user_id.clone()), platform_metadata, - login_time, - message.farcaster_id, - None, + chrono::Utc::now(), ) .await .map_err(handle_db_error)?; @@ -546,7 +527,7 @@ } else { let Some(user_id) = self .client - .get_user_id_from_user_info(wallet_address.clone(), &AuthType::Wallet) + .get_user_id_from_reserved_usernames_table(&wallet_address) .await .map_err(handle_db_error)? else { @@ -555,17 +536,36 @@ )); }; + // It's possible that the user attempting login is already registered + // on Ashoat's keyserver. If they are, we should try to register them if + // they're on a mobile device, otherwise we should send back a gRPC status + // code instructing them to try logging in from a mobile device first. + if platform_metadata.device_type.to_uppercase() != "ANDROID" + && platform_metadata.device_type.to_uppercase() != "IOS" + { + return Err(tonic::Status::permission_denied( + tonic_status_messages::RETRY_FROM_NATIVE, + )); + }; + + let social_proof = + SocialProof::new(message.siwe_message, message.siwe_signature); + self .check_device_id_taken(&flattened_device_key_upload, Some(&user_id)) .await?; self .client - .add_user_device( - user_id.clone(), + .add_wallet_user_to_users_table( flattened_device_key_upload.clone(), + wallet_address.clone(), + social_proof, + Some(user_id.clone()), platform_metadata, - chrono::Utc::now(), + login_time, + message.farcaster_id, + None, ) .await .map_err(handle_db_error)?;