mirror of
https://github.com/shiroyashik/sculptor.git
synced 2025-12-06 13:01:12 +03:00
The user system has been refactored
This commit is contained in:
parent
3d64d60b2b
commit
703a2727e7
6 changed files with 149 additions and 87 deletions
20
src/utils.rs
20
src/utils.rs
|
|
@ -1,10 +1,12 @@
|
|||
use std::{fs::File, io::Read};
|
||||
use std::{fs::File, io::Read, str::FromStr};
|
||||
|
||||
use base64::prelude::*;
|
||||
use rand::{distributions::Alphanumeric, thread_rng, Rng};
|
||||
use ring::digest::{self, digest};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::auth::{AuthSystem, Userinfo};
|
||||
|
||||
// Core functions
|
||||
pub fn rand() -> [u8; 50] {
|
||||
let mut rng = thread_rng();
|
||||
|
|
@ -34,6 +36,22 @@ pub fn get_correct_array(value: &toml::Value) -> Vec<u8> {
|
|||
.map(move |x| x.as_integer().unwrap() as u8)
|
||||
.collect()
|
||||
}
|
||||
pub fn collect_advanced_users(value: &toml::Table) -> Vec<(Uuid, Userinfo)> {
|
||||
value
|
||||
.iter()
|
||||
.map( |(uuid, userdata)| {
|
||||
let auth_system = AuthSystem::from_str(userdata.as_table().unwrap().get("authSystem").expect("Can't find authSystem in advancedUser!").as_str().unwrap()).unwrap();
|
||||
let username = userdata.as_table().unwrap().get("username").expect("Can't find username in advancedUser!").as_str().unwrap().to_string();
|
||||
(
|
||||
Uuid::parse_str(uuid).unwrap(),
|
||||
Userinfo { username,
|
||||
uuid: Uuid::parse_str(uuid).unwrap(),
|
||||
auth_system,
|
||||
token: None
|
||||
}
|
||||
)})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn format_uuid(uuid: &Uuid) -> String {
|
||||
// let uuid = Uuid::parse_str(&uuid)?; TODO: Вероятно format_uuid стоит убрать
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue