mirror of
https://github.com/LukeMathWalker/zero-to-production.git
synced 2024-05-18 16:28:08 +00:00
15 lines
479 B
Rust
15 lines
479 B
Rust
use crate::session_state::TypedSession;
|
|
use crate::utils::{e500, see_other};
|
|
use actix_web::HttpResponse;
|
|
use actix_web_flash_messages::FlashMessage;
|
|
|
|
pub async fn log_out(session: TypedSession) -> Result<HttpResponse, actix_web::Error> {
|
|
if session.get_user_id().map_err(e500)?.is_none() {
|
|
Ok(see_other("/login"))
|
|
} else {
|
|
session.log_out();
|
|
FlashMessage::info("You have successfully logged out.").send();
|
|
Ok(see_other("/login"))
|
|
}
|
|
}
|