feat(auth): Better Auth, kullanıcı adı ile giriş, DAL ve proxy
- MongoDB/Mongoose bağlantıları, kayıt kapalı, admin + username plugin, rate limit - DAL: getCurrentUser, requireSession, requireRole, getActionUser - Kullanıcı adı normalizasyonu: İ/I/ı → i (tr-TR 'ADMIN' → 'admın' hatası) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/**
|
||||
* E-postası olmayan kullanıcılar (ör. çocuklar) kullanıcı adıyla giriş yapar. Better Auth
|
||||
* e-postayı zorunlu tuttuğu için bunlara ayrılmış `.invalid` alan adında (RFC 2606)
|
||||
* yer tutucu bir adres verilir; arayüzde "e-posta yok" olarak gösterilir.
|
||||
*/
|
||||
export const PLACEHOLDER_EMAIL_DOMAIN = "kullanici.butcem.invalid";
|
||||
|
||||
export function placeholderEmail(username: string): string {
|
||||
return `${username}@${PLACEHOLDER_EMAIL_DOMAIN}`;
|
||||
}
|
||||
|
||||
export function isPlaceholderEmail(email: string | null | undefined): boolean {
|
||||
return Boolean(email?.toLowerCase().endsWith(`@${PLACEHOLDER_EMAIL_DOMAIN}`));
|
||||
}
|
||||
|
||||
/** Kaydedilecek e-posta: girilmişse o, yoksa kullanıcı adından yer tutucu. */
|
||||
export function storedEmail(username: string, email: string | undefined): string {
|
||||
return email ?? placeholderEmail(username);
|
||||
}
|
||||
|
||||
/** Gösterilecek e-posta: yer tutucuysa undefined. */
|
||||
export function visibleEmail(email: string | null | undefined): string | undefined {
|
||||
return email && !isPlaceholderEmail(email) ? email : undefined;
|
||||
}
|
||||
Reference in New Issue
Block a user