mirror of
https://github.com/better-auth/better-auth.git
synced 2026-05-22 22:32:01 -05:00
chore: enable useDateNow lint rule (#5938)
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
"noDelete": "error"
|
||||
},
|
||||
"complexity": {
|
||||
"useDateNow": "error",
|
||||
"noUselessSwitchCase": "warn",
|
||||
"noUselessTypeConstraint": "warn"
|
||||
},
|
||||
|
||||
@@ -166,7 +166,7 @@ export default function AdminDashboard() {
|
||||
await client.admin.banUser({
|
||||
userId: banForm.userId,
|
||||
banReason: banForm.reason,
|
||||
banExpiresIn: banForm.expirationDate.getTime() - new Date().getTime(),
|
||||
banExpiresIn: banForm.expirationDate.getTime() - Date.now(),
|
||||
});
|
||||
toast.success("User banned successfully");
|
||||
setIsBanDialogOpen(false);
|
||||
|
||||
@@ -355,7 +355,7 @@ describe("api-key", async () => {
|
||||
|
||||
it("should create an API key with a custom expiresIn", async () => {
|
||||
const expiresIn = 60 * 60 * 24 * 7; // 7 days
|
||||
const expectedResult = new Date().getTime() + expiresIn;
|
||||
const expectedResult = Date.now() + expiresIn;
|
||||
const apiKey = await auth.api.createApiKey({
|
||||
body: {
|
||||
expiresIn: expiresIn,
|
||||
@@ -1176,7 +1176,7 @@ describe("api-key", async () => {
|
||||
|
||||
it("should update API key expiresIn value", async () => {
|
||||
const expiresIn = 60 * 60 * 24 * 7; // 7 days
|
||||
const expectedResult = new Date().getTime() + expiresIn;
|
||||
const expectedResult = Date.now() + expiresIn;
|
||||
const apiKey = await auth.api.updateApiKey({
|
||||
body: {
|
||||
keyId: firstApiKey.id,
|
||||
|
||||
@@ -48,7 +48,7 @@ export async function validateApiKey({
|
||||
}
|
||||
|
||||
if (apiKey.expiresAt) {
|
||||
const now = new Date().getTime();
|
||||
const now = Date.now();
|
||||
const expiresAt = new Date(apiKey.expiresAt).getTime();
|
||||
if (now > expiresAt) {
|
||||
try {
|
||||
@@ -119,7 +119,7 @@ export async function validateApiKey({
|
||||
code: "USAGE_EXCEEDED" as const,
|
||||
});
|
||||
} else if (remaining !== null) {
|
||||
let now = new Date().getTime();
|
||||
let now = Date.now();
|
||||
const refillInterval = apiKey.refillInterval;
|
||||
const refillAmount = apiKey.refillAmount;
|
||||
let lastTime = new Date(lastRefillAt ?? apiKey.createdAt).getTime();
|
||||
|
||||
Reference in New Issue
Block a user