feat: finish adding device name to login, register, and refresh endpoints

This commit is contained in:
Twig 2025-07-15 02:42:53 +02:00
parent 7872d2ec24
commit fc061738fa
No known key found for this signature in database
7 changed files with 21 additions and 29 deletions

View file

@ -1,4 +1,5 @@
use std::sync::LazyLock;
use rand::Rng;
use actix_web::{
cookie::{Cookie, SameSite, time::Duration},
@ -16,11 +17,7 @@ use serde::Serialize;
use uuid::Uuid;
use crate::{
Conn, Data,
config::Config,
error::Error,
objects::{HasIsAbove, HasUuid},
schema::users,
config::Config, error::Error, objects::{HasIsAbove, HasUuid}, schema::users, wordlist::{ADJECTIVES, ANIMALS}, Conn, Data
};
pub static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
@ -282,3 +279,10 @@ impl Data {
.await
}
}
pub fn generate_device_name() -> String {
let adjective_index = rand::rng().random_range(0..ADJECTIVES.len()-1);
let animal_index = rand::rng().random_range(0..ANIMALS.len()-1);
return [ADJECTIVES[adjective_index], ANIMALS[animal_index]].join(" ")
}