users: Add routes and methods to activate user

Signed-off-by: ATechnoHazard <amolele@gmail.com>
This commit is contained in:
sphericalkat committed 2020-07-01 23:53:15 +05:30
1 parent 328b14f986
commit d1625ce721
8 files changed
+106 -47

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
pub mod db;
pub mod errors;
pub mod phonetic_key;
pub mod users;
+14
View File
@@ -0,0 +1,14 @@
use rocket::http::{Cookie, Cookies};
use crate::utils::phonetic_key;
pub fn get_session_id(ck: &mut Cookies) -> String {
match ck.get_private("session") {
Some(c) => c.value().to_string(),
None => {
let user_id = phonetic_key::get_random_id();
ck.add_private(Cookie::new("session", user_id.clone()));
user_id
}
}
}