Skip to content

Commit 0d9319d

Browse files
committed
feat: only allow cards signing/unsigning when auto setup enabled
1 parent e0f4768 commit 0d9319d

File tree

4 files changed

+17
-1
lines changed

4 files changed

+17
-1
lines changed

src/buttons.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,9 +231,19 @@ async fn submit_up(
231231
state.ble_sig.signal(BleAction::StartScan);
232232
}
233233
2 => {
234+
if unsafe { !crate::state::AUTO_SETUP } {
235+
state_val.error_text = Some("AutoSetup Mode Disabled".to_string());
236+
return Ok(true);
237+
}
238+
234239
state_val.menu_scene = Some(MenuScene::Signing);
235240
}
236241
3 => {
242+
if unsafe { !crate::state::AUTO_SETUP } {
243+
state_val.error_text = Some("AutoSetup Mode Disabled".to_string());
244+
return Ok(true);
245+
}
246+
237247
state_val.menu_scene = Some(MenuScene::Unsigning);
238248
}
239249
4 => {} // Exit

src/state.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub static mut SIGN_KEY: u32 = 0;
1717
pub static mut TRUST_SERVER: bool = false;
1818
pub static mut FKM_TOKEN: i32 = 0;
1919
pub static mut SECURE_RFID: bool = false;
20+
pub static mut AUTO_SETUP: bool = false;
2021

2122
pub static mut EPOCH_BASE: u64 = 0;
2223
pub static mut SLEEP_STATE: bool = false;

src/structs.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ pub enum TimerPacketInner {
8686
default_locale: String,
8787
fkm_token: i32,
8888
secure_rfid: bool,
89+
auto_setup: bool,
8990
},
9091
Logs {
9192
logs: Vec<String>,

src/ws.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ pub async fn ws_task(
4949

5050
loop {
5151
unsafe { crate::state::TRUST_SERVER = false };
52+
unsafe { crate::state::SECURE_RFID = false };
53+
unsafe { crate::state::AUTO_SETUP = false };
54+
unsafe { crate::state::FKM_TOKEN = 0 };
5255

5356
let ws_fut = ws_loop(
5457
&global_state,
@@ -223,7 +226,6 @@ async fn ws_loop(
223226
if random == recv_random {
224227
unsafe { crate::state::TRUST_SERVER = true };
225228
unsafe { crate::state::FKM_TOKEN = fkm_token };
226-
unsafe { crate::state::SECURE_RFID = false };
227229
}
228230
}
229231

@@ -359,6 +361,7 @@ async fn ws_rw(
359361
default_locale,
360362
fkm_token,
361363
secure_rfid,
364+
auto_setup,
362365
} => {
363366
let mut state = global_state.state.lock().await;
364367
state.device_added = Some(added);
@@ -376,6 +379,7 @@ async fn ws_rw(
376379

377380
unsafe { crate::state::FKM_TOKEN = fkm_token };
378381
unsafe { crate::state::SECURE_RFID = secure_rfid };
382+
unsafe { crate::state::AUTO_SETUP = auto_setup };
379383
}
380384
TimerPacketInner::ApiError(e) => {
381385
// if should_reset_time reset time

0 commit comments

Comments
 (0)