Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32557564
D11072.1767251580.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D11072.1767251580.diff
View Options
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
@@ -386,24 +386,7 @@
&message.siwe_signature,
)?;
- match self
- .client
- .get_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?
- {
- None => return Err(tonic::Status::invalid_argument("invalid nonce")),
- Some(nonce) if nonce.is_expired() => {
- // we don't need to remove the nonce from the table here
- // because the DynamoDB TTL will take care of it
- return Err(tonic::Status::aborted("nonce expired"));
- }
- Some(_) => self
- .client
- .remove_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?,
- };
+ self.verify_and_remove_nonce(&parsed_message.nonce).await?;
let wallet_address = eip55(&parsed_message.address);
@@ -509,19 +492,7 @@
&message.siwe_signature,
)?;
- match self
- .client
- .get_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?
- {
- None => return Err(tonic::Status::invalid_argument("invalid nonce")),
- Some(_) => self
- .client
- .remove_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?,
- };
+ self.verify_and_remove_nonce(&parsed_message.nonce).await?;
let wallet_address = eip55(&parsed_message.address);
@@ -760,6 +731,31 @@
}
Ok(())
}
+
+ async fn verify_and_remove_nonce(
+ &self,
+ nonce: &str,
+ ) -> Result<(), tonic::Status> {
+ match self
+ .client
+ .get_nonce_from_nonces_table(nonce)
+ .await
+ .map_err(handle_db_error)?
+ {
+ None => return Err(tonic::Status::invalid_argument("invalid nonce")),
+ Some(nonce) if nonce.is_expired() => {
+ // we don't need to remove the nonce from the table here
+ // because the DynamoDB TTL will take care of it
+ return Err(tonic::Status::aborted("nonce expired"));
+ }
+ Some(nonce_data) => self
+ .client
+ .remove_nonce_from_nonces_table(&nonce_data.nonce)
+ .await
+ .map_err(handle_db_error)?,
+ };
+ Ok(())
+ }
}
#[tonic::async_trait]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Jan 1, 7:13 AM (11 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5875326
Default Alt Text
D11072.1767251580.diff (2 KB)
Attached To
Mode
D11072: [identity] Extract function to verify nonce
Attached
Detach File
Event Timeline
Log In to Comment