allow admin to create user

This commit is contained in:
2023-04-05 20:56:36 +02:00
parent ed28a50d98
commit f609ee1cb4
4 changed files with 46 additions and 4 deletions

View File

@ -89,6 +89,17 @@ impl User {
.unwrap(); //TODO: fixme
}
pub async fn create(db: &SqlitePool, name: String, is_guest: bool) -> bool {
sqlx::query!(
"INSERT INTO USER(name, is_guest) VALUES (?,?)",
name,
is_guest,
)
.execute(db)
.await
.is_ok()
}
pub async fn find_by_id(db: &SqlitePool, id: i32) -> Result<Self, sqlx::Error> {
let user: User = sqlx::query_as!(
User,