This commit is contained in:
JMARyA 2024-08-11 02:57:16 +02:00
parent 9a9e77a3bb
commit e3a0d4075f
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
3 changed files with 42 additions and 4 deletions

View file

@ -9,6 +9,8 @@ use rand::RngCore;
use serde::{Deserialize, Serialize};
use serde_json::json;
use crate::route::ToAPI;
fn gen_token(token_length: usize) -> String {
let mut token_bytes = vec![0u8; token_length];
@ -106,6 +108,15 @@ impl User {
}
}
impl ToAPI for User {
async fn api(&self) -> serde_json::Value {
json!({
"username": self.username,
"role": self.role
})
}
}
#[derive(Debug, Clone, Serialize, Deserialize, Model, Referencable)]
pub struct Session {
pub _id: String,