From 4f9df753f5be8224431795547d8a9e10d8ee8d4f Mon Sep 17 00:00:00 2001 From: Bat Date: Mon, 23 Apr 2018 12:13:49 +0100 Subject: [PATCH] Implement logout --- src/main.rs | 1 + src/routes/session.rs | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/src/main.rs b/src/main.rs index f0963d4b..bc47acac 100644 --- a/src/main.rs +++ b/src/main.rs @@ -60,6 +60,7 @@ fn main() { routes::session::new, routes::session::create, + routes::session::delete, routes::blogs::details, routes::blogs::new, diff --git a/src/routes/session.rs b/src/routes/session.rs index b9476982..06c7d04a 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -43,3 +43,10 @@ fn create(conn: DbConn, data: Form, mut cookies: Cookies) -> Result Err(NotFound(String::from(e))) } } + +#[get("/logout")] +fn delete(mut cookies: Cookies) -> Redirect { + let cookie = cookies.get_private(AUTH_COOKIE).unwrap(); + cookies.remove_private(cookie); + Redirect::to("/") +}