From 2a47588eb170c9963c1ac8262b47b9897e35a0d2 Mon Sep 17 00:00:00 2001 From: Colin McKechney Date: Fri, 28 Apr 2023 00:19:45 -0400 Subject: [PATCH] failed login results in 401 --- src/api/user.rs | 8 ++++++-- src/main.rs | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/api/user.rs b/src/api/user.rs index 9a7d291..2dbf123 100644 --- a/src/api/user.rs +++ b/src/api/user.rs @@ -36,9 +36,13 @@ pub async fn login(request: HttpRequest, body: web::Json) -> impl Respond match authenticate(net_id, password) { Some(user) => { Identity::login(&request.extensions(), net_id.into()); - web::Json(user) + web::Json(user); + HttpResponse::Ok() }, - None => web::Json(User::default()) + None => { + web::Json(User::default()); + HttpResponse::Unauthorized() + } } } diff --git a/src/main.rs b/src/main.rs index be26b33..d97575f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize}; use actix_cors::Cors; use actix_identity::IdentityMiddleware; use actix_session::{SessionMiddleware, storage::CookieSessionStore}; + mod api; static PORT: u16 = 5000;