[Fix] Anonymous users now have names
This commit is contained in:
parent
e4b687c884
commit
e8faca34e2
3 changed files with 47 additions and 4 deletions
|
|
@ -1,7 +1,8 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use dashmap::DashMap;
|
||||
use once_cell::sync::Lazy;
|
||||
use rand::Rng;
|
||||
use rand::seq::SliceRandom;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::anonymous_clients::anonymous_client_connection::AnonymousClientConnection;
|
||||
|
||||
|
|
@ -34,3 +35,17 @@ pub async fn get_anonymous_user_by_name(
|
|||
|
||||
return None;
|
||||
}
|
||||
|
||||
// TODO: implement check if taken
|
||||
pub fn generate_username() -> String {
|
||||
let adjectives = ["Swift", "Clever", "Brave", "Sneaky", "Fierce"];
|
||||
let nouns = ["Tiger", "Eagle", "Shark", "Wolf", "Dragon"];
|
||||
|
||||
let mut rng = rand::thread_rng();
|
||||
let adj = adjectives.choose(&mut rng).unwrap();
|
||||
let noun = nouns.choose(&mut rng).unwrap();
|
||||
|
||||
let number: u16 = rng.gen_range(0..10000);
|
||||
|
||||
format!("{}{}{}", adj, noun, number)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue