26 lines
625 B
Rust
26 lines
625 B
Rust
pub mod captcha;
|
|
pub mod email;
|
|
pub mod login;
|
|
pub mod logout;
|
|
pub mod me;
|
|
pub mod register;
|
|
pub mod reset_pass;
|
|
pub mod rsa;
|
|
pub mod totp;
|
|
|
|
pub(crate) fn generate_token(prefix: &str) -> String {
|
|
let mut rng = rand::thread_rng();
|
|
use rand::Rng;
|
|
let chars: String = (0..64)
|
|
.map(|_| {
|
|
let idx = rng.gen_range(0..62);
|
|
const CHARSET: &[u8] =
|
|
b"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
|
CHARSET[idx] as char
|
|
})
|
|
.collect();
|
|
format!("{}_{}", prefix, chars)
|
|
}
|
|
|
|
// constant_time_eq is provided by crate::service::util
|