Add basic uuid generation & storage

pull/13/head
~erin 2021-07-25 17:12:50 -04:00
parent ad5febd8d9
commit 625485674e
Signed by: erin
GPG Key ID: DA70E064A8C70F44
2 changed files with 5 additions and 1 deletions

View File

@ -1,4 +1,5 @@
extern crate log;
use uuid::Uuid;
use crate::file_io::*;
use rocket::http::{Cookie, Cookies};
use crate::user::*;
@ -25,7 +26,7 @@ pub fn register(data: Json<RegisterEvent>) -> JsonValue {
pronouns: data.pronouns.to_string().to_lowercase(),
session_token: "NULL".to_string(),
role: UserType::Normal,
id: Uuid::new_v4(),
};
db_add(&new_user);
@ -272,6 +273,7 @@ pub fn get_user(name: String) -> JsonValue {
"name": user.name.to_lowercase(),
"pronouns": user.pronouns,
"role": user.role,
"id": user.id.to_string(),
},
});
} else {

View File

@ -1,4 +1,5 @@
use serde::{Deserialize, Serialize};
use uuid::Uuid;
/* User Data */
// enum of different user types
@ -17,6 +18,7 @@ pub struct User {
pub pronouns: String, // user's pronouns
pub session_token: String, // generated session token
pub role: UserType, // type/role of user
pub id: Uuid,
}
/* Moderation Data */