-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add detection for duplicated registration with same email
- Loading branch information
Showing
3 changed files
with
36 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use anyhow::Result; | ||
use std::sync::Arc; | ||
|
||
use aws_sdk_dynamodb::{operation::query::QueryOutput, types::AttributeValue, Client}; | ||
|
||
use super::{api_response::ApiResponse, global_variables::DYNAMO_DB_TABLE_NAME}; | ||
|
||
pub(crate) async fn get_user_from_email( | ||
dynamo_client: &Arc<Client>, | ||
email: String, | ||
) -> Result<QueryOutput> { | ||
let table_name = DYNAMO_DB_TABLE_NAME.clone(); | ||
dynamo_client | ||
.query() | ||
.table_name(table_name) | ||
.index_name("EmailIndex") // Assuming you've created a GSI named "EmailIndex" | ||
.key_condition_expression("email = :email") | ||
.expression_attribute_values(":email", AttributeValue::S(email)) | ||
.select(aws_sdk_dynamodb::types::Select::AllAttributes) | ||
.send() | ||
.await | ||
.map_err(anyhow::Error::from) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters