Can update account information
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
use crate::connections::db_connection::db;
|
||||
use crate::controllers::server_controller::ServerConstraints;
|
||||
use crate::models::accounts::{Account, AccountID, NewAccount};
|
||||
use crate::models::users::UserID;
|
||||
use crate::schema::accounts;
|
||||
@ -11,6 +12,18 @@ pub struct UpdateAccountQuery {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
impl UpdateAccountQuery {
|
||||
pub fn check_error(&self) -> Option<&'static str> {
|
||||
let constraints = ServerConstraints::default();
|
||||
|
||||
if !constraints.account_name.check_str(&self.name) {
|
||||
return Some("Invalid account name length!");
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new account
|
||||
pub async fn create(user_id: UserID, query: &UpdateAccountQuery) -> anyhow::Result<Account> {
|
||||
let new_account = NewAccount {
|
||||
|
Reference in New Issue
Block a user