diff --git a/services/identity/src/grpc_services/authenticated.rs b/services/identity/src/grpc_services/authenticated.rs --- a/services/identity/src/grpc_services/authenticated.rs +++ b/services/identity/src/grpc_services/authenticated.rs @@ -262,13 +262,24 @@ Some(Identifier::WalletAddress(address)) => (address, AuthType::Wallet), }; - let user_id = self - .db_client - .get_user_id_from_user_info(user_ident, &auth_type) - .await - .map_err(handle_db_error)?; - - Ok(Response::new(FindUserIdResponse { user_id })) + let (is_reserved_result, user_id_result) = tokio::join!( + self + .db_client + .username_in_reserved_usernames_table(&user_ident), + self + .db_client + .get_user_id_from_user_info(user_ident.clone(), &auth_type), + ); + let username_reserved = is_reserved_result.map_err(handle_db_error)?; + let user_id = user_id_result.map_err(handle_db_error)?; + + // should be true only for reserved usernames that are not registered with Identity + let is_reserved = username_reserved && user_id.is_none(); + + Ok(Response::new(FindUserIdResponse { + user_id, + is_reserved, + })) } async fn update_user_password_start( diff --git a/shared/protos/identity_authenticated.proto b/shared/protos/identity_authenticated.proto --- a/shared/protos/identity_authenticated.proto +++ b/shared/protos/identity_authenticated.proto @@ -126,8 +126,12 @@ } message FindUserIDResponse { - // none if user not found + // userID if the user is registered with Identity Service, null otherwise optional string userID = 1; + // true if the identifier (username or wallet address) exists in the + // reserved usernames list, false otherwise. This is always false + // when the user is registered with Identity Service (userID != null). + bool is_reserved = 2; } // UpdateUserPassword