From 625485674e3e9ca1f9fe9ce8831f81302a977761 Mon Sep 17 00:00:00 2001 From: Erin Nova Date: Sun, 25 Jul 2021 17:12:50 -0400 Subject: [PATCH] Add basic uuid generation & storage --- src/auth.rs | 4 +++- src/user.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/auth.rs b/src/auth.rs index 8cdc84f..f29b314 100644 --- a/src/auth.rs +++ b/src/auth.rs @@ -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) -> 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 { diff --git a/src/user.rs b/src/user.rs index c7fe77c..3d43855 100644 --- a/src/user.rs +++ b/src/user.rs @@ -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 */