aboutsummaryrefslogtreecommitdiff
path: root/src/handlers/auth.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/handlers/auth.rs')
-rw-r--r--src/handlers/auth.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/handlers/auth.rs b/src/handlers/auth.rs
index c00fb8d..ab72bc8 100644
--- a/src/handlers/auth.rs
+++ b/src/handlers/auth.rs
@@ -82,6 +82,18 @@ pub async fn register_post(Form(reg): Form<RegisterForm>, state: Extension<Arc<S
Ok(Redirect::to("/dash/auth/login"))
}
+pub async fn logout_post(jar: PrivateCookieJar) -> Result<(PrivateCookieJar, Redirect), ServiceError> {
+ if let Some(id) = jar.get("user-id") {
+ debug!("Found user {}", id);
+
+ let updated_jar = jar.remove(id);
+
+ Ok((updated_jar, Redirect::to("/dash/auth/login")))
+ } else {
+ Ok((jar, Redirect::to("/")))
+ }
+}
+
#[instrument]
pub async fn get_user_or_403(jar: PrivateCookieJar, conn: &mut PoolConnection<Postgres>) -> Result<DbUser, ServiceError> {
debug!("Starting middleware get_user_or_403");