Implement logout

This commit is contained in:
Bat 2018-04-23 12:13:49 +01:00
parent 00e5f28d0b
commit 4f9df753f5
2 changed files with 8 additions and 0 deletions

View file

@ -60,6 +60,7 @@ fn main() {
routes::session::new, routes::session::new,
routes::session::create, routes::session::create,
routes::session::delete,
routes::blogs::details, routes::blogs::details,
routes::blogs::new, routes::blogs::new,

View file

@ -43,3 +43,10 @@ fn create(conn: DbConn, data: Form<LoginForm>, mut cookies: Cookies) -> Result<R
Err(e) => Err(NotFound(String::from(e))) Err(e) => 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("/")
}