diff options
author | metamuffin <metamuffin@disroot.org> | 2023-01-22 14:10:15 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-01-22 14:10:15 +0100 |
commit | ed870d1fc04891e79ab1d40be473a07810a62e69 (patch) | |
tree | 9955a00484b3311dfd4ea8121b7b4bb3654c0f86 /server/src/routes/ui/account | |
parent | ec76bbe5398f51ffa55bfd315b30c0a07245d4e6 (diff) | |
download | jellything-ed870d1fc04891e79ab1d40be473a07810a62e69.tar jellything-ed870d1fc04891e79ab1d40be473a07810a62e69.tar.bz2 jellything-ed870d1fc04891e79ab1d40be473a07810a62e69.tar.zst |
clean again
Diffstat (limited to 'server/src/routes/ui/account')
-rw-r--r-- | server/src/routes/ui/account/mod.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/server/src/routes/ui/account/mod.rs b/server/src/routes/ui/account/mod.rs index 74710d9..bdc6062 100644 --- a/server/src/routes/ui/account/mod.rs +++ b/server/src/routes/ui/account/mod.rs @@ -74,6 +74,19 @@ pub fn r_account_login() -> DynLayoutPage<'static> { } } +#[get("/account/logout")] +pub fn r_account_logout() -> DynLayoutPage<'static> { + LayoutPage { + title: "Log out".to_string(), + content: markup::new! { + h1 { "Log out" } + form[method="POST", action=""] { + input[type="submit", value="Log out."]; + } + }, + } +} + #[post("/account/register", data = "<form>")] pub fn r_account_register_post<'a>( database: &'a State<Database>, @@ -139,6 +152,12 @@ pub fn r_account_login_post( Ok(Redirect::found(uri!(r_home()))) } +#[post("/account/logout")] +pub fn r_account_logout_post(jar: &CookieJar) -> MyResult<Redirect> { + jar.remove_private(Cookie::named("user")); + Ok(Redirect::found(uri!(r_home()))) +} + fn format_form_error<T>(form: Form<Contextual<T>>) -> MyError { let mut k = String::from("form validation failed:"); for e in form.context.errors() { |