f3936f60a3
将Argon2密码操作移出异步执行器并限制并发 统一未知停用和非法账号的登录校验与错误语义 隔离登录凭据快照和普通账号公开契约 调整管理员显示名查询顺序避免写入伪失败 新增后台账号procedure身份与事务集成烟测 同步后台账号技术方案与开发验证文档
107 lines
3.9 KiB
Rust
107 lines
3.9 KiB
Rust
use super::*;
|
|
|
|
impl SpacetimeClient {
|
|
pub async fn get_admin_account_by_username(
|
|
&self,
|
|
username: String,
|
|
) -> Result<AdminAccountCredentialRecord, SpacetimeClientError> {
|
|
let input = AdminAccountGetByUsernameInput { username };
|
|
self.call_after_connect(
|
|
"get_admin_account_by_username_and_return",
|
|
move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_admin_account_by_username_and_return_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_admin_account_credential_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
},
|
|
)
|
|
.await
|
|
}
|
|
|
|
pub async fn get_admin_account_by_id(
|
|
&self,
|
|
account_id: String,
|
|
) -> Result<AdminAccountRecord, SpacetimeClientError> {
|
|
let input = AdminAccountGetByIdInput { account_id };
|
|
self.call_after_connect(
|
|
"get_admin_account_by_id_and_return",
|
|
move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.get_admin_account_by_id_and_return_then(input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_admin_account_single_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
},
|
|
)
|
|
.await
|
|
}
|
|
|
|
pub async fn list_admin_accounts(
|
|
&self,
|
|
) -> Result<Vec<AdminAccountRecord>, SpacetimeClientError> {
|
|
self.call_after_connect(
|
|
"list_admin_accounts_and_return",
|
|
move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.list_admin_accounts_and_return_then(move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_admin_account_list_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
},
|
|
)
|
|
.await
|
|
}
|
|
|
|
pub async fn create_admin_account(
|
|
&self,
|
|
input: AdminAccountCreateRecordInput,
|
|
) -> Result<AdminAccountRecord, SpacetimeClientError> {
|
|
let procedure_input = input.into();
|
|
self.call_after_connect(
|
|
"create_admin_account_and_return",
|
|
move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.create_admin_account_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_admin_account_single_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
},
|
|
)
|
|
.await
|
|
}
|
|
|
|
pub async fn update_admin_account(
|
|
&self,
|
|
input: AdminAccountUpdateRecordInput,
|
|
) -> Result<AdminAccountRecord, SpacetimeClientError> {
|
|
let procedure_input = input.into();
|
|
self.call_after_connect(
|
|
"update_admin_account_and_return",
|
|
move |connection, sender| {
|
|
connection
|
|
.procedures()
|
|
.update_admin_account_and_return_then(procedure_input, move |_, result| {
|
|
let mapped = result
|
|
.map_err(SpacetimeClientError::from_sdk_error)
|
|
.and_then(map_admin_account_single_procedure_result);
|
|
send_once(&sender, mapped);
|
|
});
|
|
},
|
|
)
|
|
.await
|
|
}
|
|
}
|