pinakes-server: fix session token generation to use manual charset

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I80848fad9272ea7c199b17124ce767ce6a6a6964
This commit is contained in:
raf 2026-02-10 12:32:06 +03:00
commit 83af8ec5b4
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF

View file

@ -73,11 +73,14 @@ pub async fn login(
let user = user.expect("user should exist at this point"); let user = user.expect("user should exist at this point");
// Generate session token // Generate session token
use rand::Rng; let token: String = (0..48)
let token: String = rand::rng() .map(|_| {
.sample_iter(&rand::distr::Alphanumeric) const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
.take(48) abcdefghijklmnopqrstuvwxyz\
.map(char::from) 0123456789";
let idx = (rand::random::<u32>() as usize) % CHARSET.len();
CHARSET[idx] as char
})
.collect(); .collect();
let role = user.role; let role = user.role;