This commit is contained in:
2025-10-04 14:32:13 +01:00
parent 1cfc5774ad
commit 7efac1ae33
10 changed files with 1114 additions and 94 deletions
+30
View File
@@ -0,0 +1,30 @@
use rocket::{post, serde::json::Json};
use rocket_db_pools::{Connection, Database, sqlx};
use serde::{Deserialize, Serialize};
#[derive(Database)]
#[database("postgres_db")]
pub struct DbConn(sqlx::PgPool);
#[derive(Serialize, Deserialize)]
pub struct UserCredentials {
pub username: String,
pub password: String,
}
#[post("/signup", data = "<cred>")]
pub async fn signup(
conn: Connection<DbConn>,
cred: Json<UserCredentials>,
) -> Result<Json<String>, String> {
Ok(Json("Signup successful".to_string()))
}
#[post("/login", data = "<cred>")]
pub async fn login(
conn: Connection<DbConn>,
cred: Json<UserCredentials>,
) -> Result<Json<String>, String> {
// TODO: implement actual login logic, e.g. verify password and generate token
Ok(Json("Login successful".to_string()))
}