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
All checks were successful
/ test (push) Successful in 15m11s
This commit is contained in:
parent
4225fcb36f
commit
08fe5949be
6 changed files with 41 additions and 16 deletions
|
|
@ -63,11 +63,10 @@ where C: ConnectionTrait {
|
|||
panic!("Username {username} already in use");
|
||||
} else {
|
||||
let password = password_t.to_string();
|
||||
let mut new_user = user::ActiveModel {
|
||||
let new_user = user::ActiveModel {
|
||||
id: NotSet,
|
||||
username: Set(username.clone()),
|
||||
hashed_password: Set(hash_password(password)),
|
||||
owner_id: Set(None)
|
||||
};
|
||||
let res = new_user.clone().insert(db_conn).await.unwrap();
|
||||
|
||||
|
|
@ -76,10 +75,9 @@ where C: ConnectionTrait {
|
|||
user_id: Set(res.id),
|
||||
first_name: Set(format!("{username} first name")),
|
||||
last_name: Set(format!("{username} last name")),
|
||||
contact: Set(format!("{username}@mail.com"))
|
||||
contact: Set(format!("{username}@mail.com")),
|
||||
user: Set(true)
|
||||
};
|
||||
let owner_res = new_owner.insert(db_conn).await.unwrap();
|
||||
new_user.owner_id = Set(Some(owner_res.id));
|
||||
let _ = new_user.update(db_conn);
|
||||
let _ = new_owner.insert(db_conn).await.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue