aboutsummaryrefslogtreecommitdiff
path: root/src/controller/login.rs
diff options
context:
space:
mode:
authorJoris2023-11-25 08:59:39 +0100
committerJoris2023-11-25 08:59:39 +0100
commitbb906d8ecc796f6b71dda1851d6bd0aa91c6bce5 (patch)
treecf98c0d9466e0338992c94060d09ac90862178c5 /src/controller/login.rs
parent936871e6ba92a23b1956b30272af8c96951c7c2d (diff)
downloadbudget-main.tar.gz
budget-main.tar.bz2
budget-main.zip
Upgrade dependenciesmain
Diffstat (limited to 'src/controller/login.rs')
-rw-r--r--src/controller/login.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/controller/login.rs b/src/controller/login.rs
index 036e6fc..dd50a3a 100644
--- a/src/controller/login.rs
+++ b/src/controller/login.rs
@@ -1,6 +1,8 @@
use bcrypt;
+use http_body_util::Full;
+use hyper::body::Bytes;
use hyper::header::SET_COOKIE;
-use hyper::{Body, Response};
+use hyper::Response;
use sqlx::sqlite::SqlitePool;
use std::collections::HashMap;
use tera::{Context, Tera};
@@ -18,7 +20,7 @@ pub async fn page(
assets: &HashMap<String, String>,
templates: &Tera,
error: Option<&str>,
-) -> Response<Body> {
+) -> Response<Full<Bytes>> {
let connected_user: Option<User> = None;
let mut context = Context::new();
@@ -34,7 +36,7 @@ pub async fn login(
templates: &Tera,
form: HashMap<String, String>,
pool: SqlitePool,
-) -> Response<Body> {
+) -> Response<Full<Bytes>> {
match validation::login::login(&form) {
Some(login) => {
match db::users::get_password_hash(&pool, login.email.clone()).await
@@ -88,14 +90,14 @@ async fn server_error(
assets: &HashMap<String, String>,
templates: &Tera,
msg: &str,
-) -> Response<Body> {
+) -> Response<Full<Bytes>> {
page(assets, templates, Some(msg)).await
}
async fn not_authorized(
assets: &HashMap<String, String>,
templates: &Tera,
-) -> Response<Body> {
+) -> Response<Full<Bytes>> {
page(
assets,
templates,
@@ -104,7 +106,7 @@ async fn not_authorized(
.await
}
-pub async fn logout(config: &Config, wallet: &Wallet) -> Response<Body> {
+pub async fn logout(config: &Config, wallet: &Wallet) -> Response<Full<Bytes>> {
if db::users::remove_login_token(&wallet.pool, wallet.user.id).await {
with_headers(
utils::redirect("/"),