feat: GET self owner and refactor self owner to remove circular dependency between user and owner
All checks were successful
/ test (push) Successful in 15m11s

This commit is contained in:
Ninjdai 2025-08-14 12:29:47 +02:00
parent 4225fcb36f
commit 08fe5949be
6 changed files with 41 additions and 16 deletions

View file

@ -59,11 +59,10 @@ pub async fn manage_users(db: Arc<DatabaseConnection>) {
.with_validator(min_length!(10))
.with_display_mode(inquire::PasswordDisplayMode::Masked)
.prompt().unwrap();
let mut new_user = user::ActiveModel {
let new_user = user::ActiveModel {
id: NotSet,
username: Set(username),
hashed_password: Set(hash_password(password)),
owner_id: Set(None)
hashed_password: Set(hash_password(password))
};
let res = new_user.clone().insert(db.as_ref()).await.unwrap();
@ -76,11 +75,10 @@ pub async fn manage_users(db: Arc<DatabaseConnection>) {
user_id: Set(res.id),
first_name: Set(first_name),
last_name: Set(last_name),
contact: Set(contact)
contact: Set(contact),
user: Set(true)
};
let owner_res = new_owner.insert(db.as_ref()).await.unwrap();
new_user.owner_id = Set(Some(owner_res.id));
let _ = new_user.update(db.as_ref());
let _ = new_owner.insert(db.as_ref()).await.unwrap();
}
},
Action::Delete => {