feat: finish adding device name to login, register, and refresh endpoints
This commit is contained in:
parent
7872d2ec24
commit
fc061738fa
7 changed files with 21 additions and 29 deletions
14
src/utils.rs
14
src/utils.rs
|
@ -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(" ")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue