aboutsummaryrefslogtreecommitdiff
path: root/src/controller/login.rs
diff options
context:
space:
mode:
authorJoris2023-08-12 22:20:23 +0200
committerJoris2023-08-12 22:51:07 +0200
commit273bed103c37c81d477998a46873437733ffc16e (patch)
tree38476ed04c58d49207f5b4b61c651c1b72188a8a /src/controller/login.rs
parent8c689db1c8fa06ddb9119e626e7b1149f3493905 (diff)
Generate crypto random token instead of uuid
Diffstat (limited to 'src/controller/login.rs')
-rw-r--r--src/controller/login.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/controller/login.rs b/src/controller/login.rs
index 9757c25..036e6fc 100644
--- a/src/controller/login.rs
+++ b/src/controller/login.rs
@@ -4,7 +4,6 @@ use hyper::{Body, Response};
use sqlx::sqlite::SqlitePool;
use std::collections::HashMap;
use tera::{Context, Tera};
-use uuid::Uuid;
use crate::controller::utils::with_headers;
use crate::controller::wallet::Wallet;
@@ -29,7 +28,6 @@ pub async fn page(
utils::template(assets, templates, "login.html", context)
}
-// TODO rewrite
pub async fn login(
config: &Config,
assets: &HashMap<String, String>,
@@ -43,8 +41,7 @@ pub async fn login(
{
Some(hash) => match bcrypt::verify(login.password, &hash) {
Ok(true) => {
- // TODO generate truly random instead of uuid
- let login_token = Uuid::new_v4();
+ let login_token = cookie::generate_token();
if db::users::set_login_token(
&pool,
@@ -53,7 +50,7 @@ pub async fn login(
)
.await
{
- match cookie::login(config, login_token) {
+ match cookie::login(config, &login_token) {
Ok(str) => with_headers(
utils::redirect("/"),
vec![(SET_COOKIE, &str)],