DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

c4de093f521dd6e4c6574f826e6a22f43a75b294 — Jonni Liljamo 1 year, 7 months ago 5d0b519
feat(api): logout endpoint
2 files changed, 12 insertions(+), 1 deletions(-)

M api/src/handlers/user/mod.rs
M api/src/main.rs
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()