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:
@@ -32,6 +32,20 @@ pub async fn ping(db: &Database) -> mongodb::error::Result<()> {
|
||||
db.run_command(doc! { "ping": 1 }).await.map(|_| ())
|
||||
}
|
||||
|
||||
/// Benzersiz indeks ihlali mi? (ör. aynı e-postayla ikinci kayıt — hata kodu 11000)
|
||||
pub fn is_duplicate_key(e: &mongodb::error::Error) -> bool {
|
||||
use mongodb::error::{ErrorKind, WriteFailure};
|
||||
match e.kind.as_ref() {
|
||||
ErrorKind::Write(WriteFailure::WriteError(we)) => we.code == 11000,
|
||||
ErrorKind::Command(ce) => ce.code == 11000,
|
||||
ErrorKind::InsertMany(ime) => ime
|
||||
.write_errors
|
||||
.as_ref()
|
||||
.is_some_and(|errs| errs.iter().any(|we| we.code == 11000)),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Açılışta çalışır: bekleyen migration'lar, ardından indeksler.
|
||||
/// İkisi de tekrar çalıştırılabilir (idempotent); zaten yapılmış olanı atlar.
|
||||
pub async fn prepare(db: &Database) -> mongodb::error::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user