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:
parent
2717a59fe2
commit
83af8ec5b4
1 changed files with 8 additions and 5 deletions
|
|
@ -73,11 +73,14 @@ pub async fn login(
|
|||
let user = user.expect("user should exist at this point");
|
||||
|
||||
// Generate session token
|
||||
use rand::Rng;
|
||||
let token: String = rand::rng()
|
||||
.sample_iter(&rand::distr::Alphanumeric)
|
||||
.take(48)
|
||||
.map(char::from)
|
||||
let token: String = (0..48)
|
||||
.map(|_| {
|
||||
const CHARSET: &[u8] = b"ABCDEFGHIJKLMNOPQRSTUVWXYZ\
|
||||
abcdefghijklmnopqrstuvwxyz\
|
||||
0123456789";
|
||||
let idx = (rand::random::<u32>() as usize) % CHARSET.len();
|
||||
CHARSET[idx] as char
|
||||
})
|
||||
.collect();
|
||||
|
||||
let role = user.role;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue