feat: logout button

This commit is contained in:
Max Hohlfeld 2024-05-12 15:24:03 +02:00
parent 2f5cc33261
commit 76b0d70a01
4 changed files with 14 additions and 2 deletions

View File

@ -29,6 +29,7 @@ pub fn init(cfg: &mut ServiceConfig) {
cfg.service(user::post_edit::post_edit); cfg.service(user::post_edit::post_edit);
cfg.service(user::patch::patch); cfg.service(user::patch::patch);
cfg.service(user::delete::delete); cfg.service(user::delete::delete);
cfg.service(user::get_logout::get);
cfg.service(events::get_new::get); cfg.service(events::get_new::get);
cfg.service(events::post_new::post); cfg.service(events::post_new::post);

View File

@ -0,0 +1,10 @@
use actix_identity::Identity;
use actix_web::{http::header::LOCATION, HttpResponse, Responder};
#[actix_web::get("/logout")]
pub async fn get(user: Identity) -> impl Responder {
user.logout();
HttpResponse::Found().insert_header((LOCATION, "/")).finish()
}

View File

@ -5,3 +5,4 @@ pub mod get_edit;
pub mod post_edit; pub mod post_edit;
pub mod patch; pub mod patch;
pub mod delete; pub mod delete;
pub mod get_logout;

View File

@ -16,7 +16,7 @@
<div class="navbar-menu"> <div class="navbar-menu">
<div class="navbar-start"> <div class="navbar-start">
<a class="navbar-item"> <a href="/" class="navbar-item">
Kalender Kalender
</a> </a>
@ -52,7 +52,7 @@
<a class="button is-primary"> <a class="button is-primary">
Profil Profil
</a> </a>
<a class="button is-light"> <a href="/logout" class="button is-light">
Abmelden Abmelden
</a> </a>
</div> </div>