feat: add logout functionality and redesign desktop client UI for simplified workflow
Add clear_session command to remove session state and profile files from disk. Add resetEnrollment handler in frontend to clear local state and invoke clear_session. Remove hero surface section with profile metadata tiles. Simplify top strip to show profile label in brand copy when enrolled. Add Logout button to top actions and resources sidebar. Redesign status panel with simplified labels and layout. Update surface
This commit is contained in:
@@ -213,6 +213,24 @@ fn load_state(app: AppHandle, state: State<'_, AppState>) -> Result<Option<Enrol
|
||||
Ok(loaded.map(|value| value.enrollment))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn clear_session(app: AppHandle, state: State<'_, AppState>) -> Result<(), String> {
|
||||
let app_dir = ensure_app_dir(&app)?;
|
||||
let session_path = app_dir.join("session.json");
|
||||
let profile_path = app_dir.join(format!("{}.conf", PROFILE_NAME));
|
||||
|
||||
if session_path.exists() {
|
||||
fs::remove_file(&session_path).map_err(|err| format!("Unable to remove session state: {}", err))?;
|
||||
}
|
||||
if profile_path.exists() {
|
||||
fs::remove_file(&profile_path).map_err(|err| format!("Unable to remove profile: {}", err))?;
|
||||
}
|
||||
|
||||
let mut session = state.session.lock().map_err(|_| "Unable to clear client state".to_string())?;
|
||||
*session = None;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
async fn sync_profile(app: AppHandle, state: State<'_, AppState>) -> Result<EnrollmentResult, String> {
|
||||
let existing = {
|
||||
@@ -417,7 +435,7 @@ pub fn run() {
|
||||
}
|
||||
_ => {}
|
||||
})
|
||||
.invoke_handler(tauri::generate_handler![load_state, enroll_device, sync_profile, connect_tunnel, disconnect_tunnel])
|
||||
.invoke_handler(tauri::generate_handler![load_state, clear_session, enroll_device, sync_profile, connect_tunnel, disconnect_tunnel])
|
||||
.run(tauri::generate_context!())
|
||||
.expect("error while running tauri application");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user