5191a5cce1
- 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>
9 lines
384 B
TypeScript
9 lines
384 B
TypeScript
import { isAPIError } from "better-auth/api";
|
||
|
||
/** Better Auth hatasından makine okunur kodu çıkarır (ör. "USERNAME_IS_ALREADY_TAKEN"). */
|
||
export function authErrorCode(error: unknown): string | undefined {
|
||
if (!isAPIError(error)) return undefined;
|
||
const body = error.body as { code?: unknown } | undefined;
|
||
return typeof body?.code === "string" ? body.code : undefined;
|
||
}
|