ISSUE-3: Fix case-sensitive handles.
This commit is contained in:
parent
10e947df92
commit
7292e52d2c
@ -90,7 +90,10 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
|
||||
if is_valid && request.secret.len() == 0 { response.status = STATUS_BAD_SECRET; is_valid = false; }
|
||||
|
||||
if is_valid {
|
||||
match app.user_handle.get(request.handle.as_bytes()) {
|
||||
let handle = request.handle.to_lowercase();
|
||||
let display_name = request.handle.clone();
|
||||
|
||||
match app.user_handle.get(handle.as_bytes()) {
|
||||
None => {
|
||||
let mut salt = [0u8; 16];
|
||||
match rng.fill(&mut salt) {
|
||||
@ -102,13 +105,13 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
|
||||
let user_id = app.filesystem.user_count().unwrap() as u32;
|
||||
|
||||
// Register user pool id and handle
|
||||
let handle_id = app.filesystem.handle_store(&request.handle, user_id).unwrap();
|
||||
app.user_handle.set(request.handle.as_bytes(), user_id);
|
||||
let handle_id = app.filesystem.handle_store(&handle, user_id).unwrap();
|
||||
app.user_handle.set(handle.as_bytes(), user_id);
|
||||
|
||||
let user_data = User {
|
||||
id:user_id,
|
||||
handle_id,
|
||||
handle:request.handle.clone(),
|
||||
handle:display_name,
|
||||
secret,
|
||||
na_key:salt_id,
|
||||
};
|
||||
@ -170,7 +173,7 @@ pub async fn thread_system(mut app:App, bus:Bus<protocol::QRPacket>)
|
||||
if is_valid {
|
||||
|
||||
// Get user data from handle
|
||||
match app.user_handle.get(request.handle.as_bytes()) {
|
||||
match app.user_handle.get(request.handle.to_lowercase().as_bytes()) {
|
||||
Some(uid) => {
|
||||
if let Some(tuid) = app.user_id.get(*uid as isize) {
|
||||
if let Some(user) = app.users.get(*tuid) {
|
||||
|
@ -305,11 +305,15 @@ impl FileSystem {
|
||||
let file_path = bucket_path.join(format!("{:08x}.bin", file_index));
|
||||
if let Ok(mut file) = File::options().write(true).create(true).open(file_path) {
|
||||
|
||||
let handle = user.handle.as_bytes().to_vec();
|
||||
|
||||
// Write user information
|
||||
file.write(&pack_u32(user.handle_id)).map_err(|_| ())?;
|
||||
file.write(&pack_u32(user.na_key)).map_err(|_| ())?;
|
||||
file.write(&pack_u16(user.secret.len() as u16)).map_err(|_| ())?;
|
||||
file.write(&user.secret).map_err(|_| ())?;
|
||||
file.write(&pack_u8(handle.len() as u8)).map_err(|_| ())?;
|
||||
file.write(&handle).map_err(|_| ())?;
|
||||
|
||||
Ok(size)
|
||||
} else { Err(()) }
|
||||
@ -331,6 +335,7 @@ impl FileSystem {
|
||||
file.seek(SeekFrom::Start(0)).map_err(|_| ())?;
|
||||
|
||||
// Extract user information
|
||||
let mut buffer_u8 = [0u8; 1];
|
||||
let mut buffer_u16 = [0u8; 2];
|
||||
let mut buffer_u32 = [0u8; 4];
|
||||
|
||||
@ -346,7 +351,13 @@ impl FileSystem {
|
||||
let mut secret = vec![0u8; secret_length as usize];
|
||||
file.read_exact(&mut secret).map_err(|_| ())?;
|
||||
|
||||
let (handle, _) = self.handle_fetch(handle_id)?;
|
||||
file.read_exact(&mut buffer_u8).map_err(|_| ())?;
|
||||
let handle_length = unpack_u8(&buffer_u8, &mut 0);
|
||||
|
||||
let mut handle = vec![0u8; handle_length as usize];
|
||||
file.read_exact(&mut handle).map_err(|_| ())?;
|
||||
|
||||
let handle = String::from_utf8(handle).map_err(|_| ())?;
|
||||
|
||||
Ok(User {
|
||||
id,
|
||||
|
@ -923,7 +923,7 @@ const INTERFACE = {
|
||||
INTERFACE_DATA.retire_warn = true;
|
||||
button_retire.innerText = "Confirm?";
|
||||
button_retire.setAttribute("class", "warn");
|
||||
setTimeout(INTERFACE.retire_reset, 5_000);
|
||||
setTimeout(INTERFACE.retire_reset, 3_000);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user