users
This commit is contained in:
parent
9a9e77a3bb
commit
e3a0d4075f
3 changed files with 42 additions and 4 deletions
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue