This commit is contained in:
eraden 2024-10-23 05:11:58 +02:00
parent 8348aae593
commit 2435549298

View File

@ -100,16 +100,24 @@ async fn sign_in(
.set_ex(uid.to_string(), "1", 60 * 60 * 24) // session exists for 1 day .set_ex(uid.to_string(), "1", 60 * 60 * 24) // session exists for 1 day
.await .await
.expect("Failed to store session"); .expect("Failed to store session");
HttpResponse::Ok() HttpResponse::SeeOther()
.cookie( .cookie(
CookieBuilder::new("ses", uid.to_string()) CookieBuilder::new("ses", uid.to_string())
.secure(true) .secure(true)
.max_age(Duration::hours(24)) .max_age(Duration::hours(24))
.finish(), .finish(),
) )
.append_header(("location", "/"))
.finish() .finish()
} else { } else {
HttpResponse::Ok().finish() HttpResponse::BadRequest().body(
SignInForm {
login: payload.login,
not_found: true,
}
.render()
.unwrap_or_default(),
)
} }
} }