M api/src/handlers/user/mod.rs => api/src/handlers/user/mod.rs +11 -1
@@ 6,10 6,20 @@
* See LICENSE for licensing information.
*/
+use actix_session::Session;
+use actix_web::{get, HttpResponse, Responder};
+
mod create;
pub(crate) use create::*;
mod login;
pub(crate) use login::*;
-pub(crate) fn logout() {}
+#[get("/api/user/logout")]
+pub(crate) async fn logout(session: Session) -> impl Responder {
+ // TODO: can anything here fail?
+ // should we verify that the session was removed?
+ session.purge();
+
+ HttpResponse::NoContent()
+}
M api/src/main.rs => api/src/main.rs +1 -0
@@ 89,6 89,7 @@ async fn main() -> std::io::Result<()> {
.service(handlers::info)
.service(handlers::user::create)
.service(handlers::user::login)
+ .service(handlers::user::logout)
})
.bind(("0.0.0.0", 8080))?
.run()