rusty-bever/src/rb/models.rs

31 lines
651 B
Rust
Raw Normal View History

2021-08-21 18:05:16 +02:00
use crate::schema::{refresh_tokens, users};
use diesel::{Insertable, Queryable, AsChangeset};
2021-08-21 13:46:41 +02:00
use serde::Serialize;
2021-08-21 18:05:16 +02:00
use uuid::Uuid;
2021-08-20 23:09:22 +02:00
2021-08-21 13:46:41 +02:00
#[derive(Queryable, Serialize)]
2021-08-20 23:09:22 +02:00
pub struct User {
2021-08-21 13:46:41 +02:00
pub id: Uuid,
pub username: String,
#[serde(skip_serializing)]
2021-08-20 23:09:22 +02:00
pub password: String,
2021-08-21 13:46:41 +02:00
#[serde(skip_serializing)]
2021-08-21 18:05:16 +02:00
pub blocked: bool,
2021-08-21 16:45:41 +02:00
pub admin: bool,
}
2021-08-21 18:05:16 +02:00
#[derive(Insertable, AsChangeset)]
#[table_name = "users"]
pub struct NewUser {
pub username: String,
pub password: String,
pub admin: bool,
}
2021-08-21 16:45:41 +02:00
#[derive(Insertable)]
#[table_name = "refresh_tokens"]
pub struct NewRefreshToken {
pub token: Vec<u8>,
2021-08-21 18:05:16 +02:00
pub user_id: Uuid,
2021-08-20 23:09:22 +02:00
}