mirror of
https://github.com/Drop-OSS/drop-app.git
synced 2025-11-16 09:41:17 +10:00
feat(account settings): Add signout functionality (#16)
* Create account.vue with logout button * Update auth.rs to add signout command * Update lib.rs to pass sign_out command to frontend
This commit is contained in:
@ -232,3 +232,29 @@ pub fn setup() -> Result<(AppStatus, Option<User>), ()> {
|
||||
|
||||
Ok((AppStatus::SignedOut, None))
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn sign_out(app: AppHandle) -> Result<(), String> {
|
||||
info!("Signing out user");
|
||||
|
||||
// Clear auth from database
|
||||
{
|
||||
let mut handle = DB.borrow_data_mut().unwrap();
|
||||
handle.auth = None;
|
||||
drop(handle);
|
||||
DB.save().unwrap();
|
||||
}
|
||||
|
||||
// Update app state
|
||||
{
|
||||
let app_state = app.state::<Mutex<AppState>>();
|
||||
let mut app_state_handle = app_state.lock().unwrap();
|
||||
app_state_handle.status = AppStatus::SignedOut;
|
||||
app_state_handle.user = None;
|
||||
}
|
||||
|
||||
// Emit event for frontend
|
||||
app.emit("auth/signedout", ()).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user