style: use const generic for token length instead of multiple functions
All checks were successful
ci/woodpecker/push/build-and-publish Pipeline was successful
ci/woodpecker/push/publish-docs Pipeline was successful

Simplifies codebase a bit and avoids having to add another function in future if we need another length of token
This commit is contained in:
Radical 2025-06-25 13:25:39 +02:00
parent f752cddd73
commit 407460d2aa
6 changed files with 16 additions and 22 deletions

View file

@ -11,7 +11,7 @@ use crate::{
error::Error,
schema::*,
utils::{
PASSWORD_REGEX, generate_access_token, generate_refresh_token, new_refresh_token_cookie,
PASSWORD_REGEX, generate_token, new_refresh_token_cookie,
user_uuid_from_identifier,
},
};
@ -59,8 +59,8 @@ pub async fn response(
));
}
let refresh_token = generate_refresh_token()?;
let access_token = generate_access_token()?;
let refresh_token = generate_token::<32>()?;
let access_token = generate_token::<16>()?;
let current_time = SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() as i64;