Page MenuHomePhabricator

D12404.id.diff
No OneTemporary

D12404.id.diff

diff --git a/native/utils/farcaster-utils.js b/native/utils/farcaster-utils.js
--- a/native/utils/farcaster-utils.js
+++ b/native/utils/farcaster-utils.js
@@ -19,10 +19,7 @@
try {
await linkFID(newFID);
} catch (e) {
- if (
- getMessageForException(e) ===
- 'farcaster ID already associated with different user'
- ) {
+ if (getMessageForException(e) === 'fid_taken') {
const { title, message } =
getFarcasterAccountAlreadyLinkedAlertDetails();
Alert.alert(title, message);
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
@@ -284,7 +284,9 @@
};
Ok(Response::new(response))
} else {
- Err(tonic::Status::not_found("session not found"))
+ Err(tonic::Status::not_found(
+ tonic_status_messages::SESSION_NOT_FOUND,
+ ))
}
}
@@ -434,7 +436,9 @@
};
Ok(Response::new(response))
} else {
- Err(tonic::Status::not_found("session not found"))
+ Err(tonic::Status::not_found(
+ tonic_status_messages::SESSION_NOT_FOUND,
+ ))
}
}
@@ -1063,7 +1067,7 @@
.is_empty();
if fid_already_registered {
return Err(tonic::Status::already_exists(
- "farcaster ID already associated with different user",
+ tonic_status_messages::FID_TAKEN,
));
}
Ok(())
diff --git a/services/identity/src/constants.rs b/services/identity/src/constants.rs
--- a/services/identity/src/constants.rs
+++ b/services/identity/src/constants.rs
@@ -233,6 +233,13 @@
pub const USER_NOT_FOUND: &str = "user_not_found";
pub const INVALID_NONCE: &str = "invalid_nonce";
pub const NONCE_EXPIRED: &str = "nonce_expired";
+ pub const FID_TAKEN: &str = "fid_taken";
+ pub const CANNOT_LINK_FID: &str = "cannot_link_fid";
+ pub const INVALID_PLATFORM_METADATA: &str = "invalid_platform_metadata";
+ pub const MISSING_CREDENTIALS: &str = "missing_credentials";
+ pub const BAD_CREDENTIALS: &str = "bad_credentials";
+ pub const SESSION_NOT_FOUND: &str = "session_not_found";
+ pub const INVALID_TIMESTAMP: &str = "invalid_timestamp";
}
// Tunnelbroker
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
@@ -51,8 +51,10 @@
) -> Result<Request<()>, Status> {
trace!("Intercepting request to check auth info: {:?}", req);
- let (user_id, device_id, access_token) = get_auth_info(&req)
- .ok_or_else(|| Status::unauthenticated("Missing credentials"))?;
+ let (user_id, device_id, access_token) =
+ get_auth_info(&req).ok_or_else(|| {
+ Status::unauthenticated(tonic_status_messages::MISSING_CREDENTIALS)
+ })?;
let handle = tokio::runtime::Handle::current();
let new_db_client = db_client.clone();
@@ -70,7 +72,7 @@
})?;
if !valid_token {
- return Err(Status::aborted("Bad Credentials"));
+ return Err(Status::aborted(tonic_status_messages::BAD_CREDENTIALS));
}
Ok(req)
@@ -294,7 +296,9 @@
.await
.map_err(handle_db_error)?
else {
- return Err(tonic::Status::not_found("session not found"));
+ return Err(tonic::Status::not_found(
+ tonic_status_messages::SESSION_NOT_FOUND,
+ ));
};
let server_registration = comm_opaque2::server::Registration::new();
@@ -505,7 +509,9 @@
.await
.map_err(handle_db_error)?
else {
- return Err(tonic::Status::not_found("session not found"));
+ return Err(tonic::Status::not_found(
+ tonic_status_messages::SESSION_NOT_FOUND,
+ ));
};
let mut server_login = state.opaque_server_login;
@@ -535,8 +541,11 @@
let since = since_timestamp
.map(|timestamp| {
- DateTime::from_timestamp_millis(timestamp)
- .ok_or_else(|| tonic::Status::invalid_argument("Invalid timestamp"))
+ DateTime::from_timestamp_millis(timestamp).ok_or_else(|| {
+ tonic::Status::invalid_argument(
+ tonic_status_messages::INVALID_TIMESTAMP,
+ )
+ })
})
.transpose()?;
@@ -691,16 +700,16 @@
errorType = error_types::GRPC_SERVICES_LOG,
"multiple users associated with the same Farcaster ID"
);
- return Err(Status::failed_precondition("cannot link Farcaster ID"));
+ return Err(Status::failed_precondition(
+ tonic_status_messages::CANNOT_LINK_FID,
+ ));
}
if let Some(u) = get_farcaster_users_response.pop() {
if u.0.user_id == user_id {
return Ok(Response::new(Empty {}));
} else {
- return Err(Status::already_exists(
- "farcaster ID already associated with different user",
- ));
+ return Err(Status::already_exists(tonic_status_messages::FID_TAKEN));
}
}
@@ -763,7 +772,11 @@
let (user_id, device_id) = get_user_and_device_id(&request)?;
let platform_metadata = get_platform_metadata(&request)?;
let platform_details = PlatformDetails::new(platform_metadata, None)
- .map_err(|_| Status::invalid_argument("Invalid platform metadata"))?;
+ .map_err(|_| {
+ Status::invalid_argument(
+ tonic_status_messages::INVALID_PLATFORM_METADATA,
+ )
+ })?;
self
.db_client

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 5, 5:15 AM (9 h, 44 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2616060
Default Alt Text
D12404.id.diff (5 KB)

Event Timeline