feat(auth): kayıt, giriş, çıkış ve oturum (argon2 + JWT httpOnly cookie)

- Kayıt: kullanıcı + hane + örnek kategori/ödeme türü tek transaction'da
- Giriş: beni hatırla (30 gün / oturum), e-posta başına deneme sınırı
- AuthUser extractor: cookie'deki JWT'yi doğrular
- ValidJson: JSON + doğrulama, Türkçe hata mesajları
- api.http: auth istekleri eklendi
- Birim testleri: şifre, JWT, deneme sınırı, seed (11 test)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-11 23:37:52 +03:00
parent 4103b90e4b
commit d6136959b1
27 changed files with 1573 additions and 32 deletions
+1 -2
View File
@@ -3,8 +3,6 @@
//! Her kayıt şu alanları taşır:
//! `_id` (UUID v7), `household_id`, `created_at`, `updated_at`, `deleted_at`, `version`
#![allow(dead_code)] // Faz 1 – Adım 3 itibarıyla kullanılacak
use mongodb::bson::{DateTime, Document, Uuid, doc};
/// Yeni UUID v7 üretir. İlk 48 bit zaman damgası olduğu için
@@ -38,6 +36,7 @@ pub fn scope(household_id: Uuid) -> Document {
doc! { "household_id": household_id, "deleted_at": null }
}
#[allow(dead_code)] // Faz 1 – Adım 5'te (kategori güncelleme) kullanılacak
/// Güncellemelerde eklenecek ortak kısım: `updated_at` yenilenir, `version` +1.
pub fn touch() -> Document {
doc! {
+19
View File
@@ -0,0 +1,19 @@
//! `households` koleksiyonu (DATA_MODEL.md §3.2).
use mongodb::bson::{Document, doc};
use serde::Deserialize;
/// Veritabanından okunan hane (yalnızca ihtiyaç duyulan alanlar).
#[derive(Debug, Deserialize)]
pub struct Household {
pub name: String,
}
/// Yeni hane için varsayılan ayarlar.
pub fn default_settings() -> Document {
doc! {
"currency": "TRY",
"budget_split_pct": { "needs": 50, "wants": 30, "culture": 10, "unexpected": 10 },
"budget_suggestion": "default",
}
}
+2
View File
@@ -2,3 +2,5 @@
//! Şema: `docs/DATA_MODEL.md`
pub mod common;
pub mod household;
pub mod user;
+32
View File
@@ -0,0 +1,32 @@
//! `users` koleksiyonu (DATA_MODEL.md §3.1).
use mongodb::bson::Uuid;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "lowercase")]
pub enum Role {
Owner,
Member,
}
impl Role {
pub fn as_str(self) -> &'static str {
match self {
Role::Owner => "owner",
Role::Member => "member",
}
}
}
/// Veritabanından okunan kullanıcı (yalnızca ihtiyaç duyulan alanlar).
#[derive(Debug, Deserialize)]
pub struct User {
#[serde(rename = "_id")]
pub id: Uuid,
pub household_id: Uuid,
pub email: String,
pub password_hash: String,
pub name: String,
pub role: Role,
}