created frontend with login, room listing and creation, and message page with all features

This commit is contained in:
2025-12-15 14:50:50 +01:00
parent 43a55a9a7c
commit 0365c7978c
2 changed files with 15 additions and 5 deletions

View File

@@ -24,8 +24,8 @@ async fn main() -> anyhow::Result<()> {
.allow_headers([header::AUTHORIZATION, header::CONTENT_TYPE]);
let governor_conf = GovernorConfigBuilder::default()
.per_second(5)
.burst_size(10)
.per_second(10)
.burst_size(20)
.finish()
.unwrap();

View File

@@ -1,13 +1,17 @@
use axum::{
Extension, Json, Router, extract::Request, http::StatusCode, middleware::Next,
response::Response, routing::post,
Extension, Json, Router,
extract::Request,
http::{HeaderMap, StatusCode},
middleware::Next,
response::Response,
routing::{get, post},
};
use sqlx::PgPool;
use std::env;
use uuid::Uuid;
use validator::ValidateEmail;
use crate::auth::{create_jwt, hash_password, verify_password};
use crate::auth::{create_jwt, hash_password, verify_jwt, verify_password};
const DUMMY_HASH: &str = "$argon2id$v=19$m=4096,t=3,p=1$YWFhYWFhYWFhYWFhYWFhYQ$aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
@@ -42,6 +46,7 @@ pub fn routes() -> Router {
Router::new()
.route("/login", post(login))
.route("/register", post(register_user))
.route("/validate-token", get(validate_token))
.layer(axum::middleware::from_fn(registration_guard))
}
@@ -144,3 +149,8 @@ pub async fn register_user(
}),
))
}
async fn validate_token(headers: HeaderMap) -> Result<String, (StatusCode, String)> {
let _ = verify_jwt(headers)?;
Ok(String::from("OK"))
}