aboutsummaryrefslogtreecommitdiff
path: root/server/src/routes/ui/account/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/routes/ui/account/mod.rs')
-rw-r--r--server/src/routes/ui/account/mod.rs19
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() {