24 lines
735 B
Rust
24 lines
735 B
Rust
use log::info;
|
|
use rouille::Response;
|
|
|
|
use crate::{utils::flash::FlashResponse, SessionData};
|
|
|
|
// ROUTE: /auth/logout (GET)
|
|
|
|
/// Deauthenticate the logged-in user by erasing the session data.
|
|
/// Redirect to the login page.
|
|
pub fn deauthenticate(session_data: &mut Option<SessionData>) -> Response {
|
|
info!("Attempting deauthentication of user.");
|
|
|
|
// erase the content of `session_data` to deauthenticate the user
|
|
*session_data = None;
|
|
|
|
let (flash_name, flash_msg) = (
|
|
"flash_name=success".to_string(),
|
|
"flash_msg=Logged out".to_string(),
|
|
);
|
|
|
|
// set the flash cookie headers and redirect to the login page
|
|
Response::redirect_303("/auth/login".to_string()).add_flash(flash_name, flash_msg)
|
|
}
|