diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs --- a/services/identity/src/database.rs +++ b/services/identity/src/database.rs @@ -3,7 +3,9 @@ use std::sync::Arc; use aws_sdk_dynamodb::model::AttributeValue; -use aws_sdk_dynamodb::output::{GetItemOutput, PutItemOutput}; +use aws_sdk_dynamodb::output::{ + GetItemOutput, PutItemOutput, UpdateItemOutput, +}; use aws_sdk_dynamodb::types::Blob; use aws_sdk_dynamodb::{Client, Error as DynamoDBError}; use aws_types::sdk_config::SdkConfig; @@ -79,14 +81,18 @@ &self, user_id: String, registration: ServerRegistration, - ) -> Result { + ) -> Result { self .client - .put_item() + .update_item() .table_name(PAKE_USERS_TABLE) - .item(PAKE_USERS_TABLE_PARTITION_KEY, AttributeValue::S(user_id)) - .item( - PAKE_USERS_TABLE_REGISTRATION_ATTRIBUTE, + .key(PAKE_USERS_TABLE_PARTITION_KEY, AttributeValue::S(user_id)) + .update_expression(format!( + "SET {} :r", + PAKE_USERS_TABLE_REGISTRATION_ATTRIBUTE + )) + .expression_attribute_values( + ":r", AttributeValue::B(Blob::new(registration.serialize())), ) .send()