Changeset View
Changeset View
Standalone View
Standalone View
services/identity/src/database.rs
Show All 28 Lines | use crate::constants::{ | ||||
USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_INDEX, | USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_INDEX, | ||||
}; | }; | ||||
use crate::nonce::NonceData; | use crate::nonce::NonceData; | ||||
use crate::token::{AccessTokenData, AuthType}; | use crate::token::{AccessTokenData, AuthType}; | ||||
use comm_opaque::Cipher; | use comm_opaque::Cipher; | ||||
#[derive(Serialize, Deserialize)] | #[derive(Serialize, Deserialize)] | ||||
pub struct OlmKeys { | pub struct OlmKeys { | ||||
curve25519: String, | pub curve25519: String, | ||||
ed25519: String, | pub ed25519: String, | ||||
} | } | ||||
#[derive(Serialize, Deserialize)] | #[derive(Serialize, Deserialize)] | ||||
#[serde(rename_all = "camelCase")] | #[serde(rename_all = "camelCase")] | ||||
pub struct KeyPayload { | pub struct KeyPayload { | ||||
pub notification_identity_public_keys: OlmKeys, | pub notification_identity_public_keys: OlmKeys, | ||||
pub primary_identity_public_keys: OlmKeys, | pub primary_identity_public_keys: OlmKeys, | ||||
} | } | ||||
▲ Show 20 Lines • Show All 351 Lines • ▼ Show 20 Lines | self | ||||
.put_item() | .put_item() | ||||
.table_name(ACCESS_TOKEN_TABLE) | .table_name(ACCESS_TOKEN_TABLE) | ||||
.set_item(Some(item)) | .set_item(Some(item)) | ||||
.send() | .send() | ||||
.await | .await | ||||
.map_err(|e| Error::AwsSdk(e.into())) | .map_err(|e| Error::AwsSdk(e.into())) | ||||
} | } | ||||
pub async fn username_available( | pub async fn username_taken(&self, username: String) -> Result<bool, Error> { | ||||
&self, | |||||
username: String, | |||||
) -> Result<bool, Error> { | |||||
let result = self | let result = self | ||||
.get_user_id_from_user_info(username, AuthType::Password) | .get_user_id_from_user_info(username, AuthType::Password) | ||||
.await?; | .await?; | ||||
Ok(result.is_none()) | Ok(result.is_some()) | ||||
} | } | ||||
pub async fn get_user_id_from_user_info( | pub async fn get_user_id_from_user_info( | ||||
&self, | &self, | ||||
user_info: String, | user_info: String, | ||||
auth_type: AuthType, | auth_type: AuthType, | ||||
) -> Result<Option<String>, Error> { | ) -> Result<Option<String>, Error> { | ||||
let (index, attribute_name) = match auth_type { | let (index, attribute_name) = match auth_type { | ||||
▲ Show 20 Lines • Show All 418 Lines • Show Last 20 Lines |