Merge branch 'generate-device-name' into staging
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
Some checks failed
ci/woodpecker/push/build-and-publish Pipeline failed
This commit is contained in:
commit
969b517e18
11 changed files with 1034 additions and 18 deletions
11
src/utils.rs
11
src/utils.rs
|
@ -1,4 +1,5 @@
|
|||
use std::sync::LazyLock;
|
||||
use rand::{seq::IndexedRandom};
|
||||
|
||||
use axum::body::Bytes;
|
||||
use axum_extra::extract::cookie::{Cookie, SameSite};
|
||||
|
@ -19,6 +20,7 @@ use crate::{
|
|||
error::Error,
|
||||
objects::{HasIsAbove, HasUuid},
|
||||
schema::users,
|
||||
wordlist::{ADJECTIVES, ANIMALS}
|
||||
};
|
||||
|
||||
pub static EMAIL_REGEX: LazyLock<Regex> = LazyLock::new(|| {
|
||||
|
@ -207,3 +209,12 @@ impl AppState {
|
|||
.await
|
||||
}
|
||||
}
|
||||
|
||||
pub fn generate_device_name() -> String {
|
||||
let mut rng = rand::rng();
|
||||
|
||||
let adjective = ADJECTIVES.choose(&mut rng).unwrap();
|
||||
let animal = ANIMALS.choose(&mut rng).unwrap();
|
||||
|
||||
return [*adjective, *animal].join(" ")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue