mirror of
https://github.com/Chewbaccalakis/rfid-database.git
synced 2026-09-10 00:11:56 -07:00
Implement RFID tag dump PWA with REST API, auth, and CI (#1)
Add Next.js app with SQLite/Drizzle storage for sites and LF/HF tag dumps, multi-user Auth.js (credentials + optional OIDC), personal API tokens in Settings, versioned /api/v1 for UI and future CLI use, MCT/Proxmark/JSON import-export, PWA offline shell, Vitest tests, and GitHub Actions CI. Co-authored-by: Cursor Agent <[email protected]>
This commit is contained in:
co-authored by
Cursor Agent
parent
5029945cc2
commit
8500d2f673
@@ -0,0 +1,27 @@
|
||||
import { eq } from "drizzle-orm";
|
||||
import { getDb, resetDbConnection } from "../src/db/client";
|
||||
import { apiTokens, users } from "../src/db/schema";
|
||||
import { generateApiToken } from "../src/lib/auth/tokens";
|
||||
|
||||
const email = process.argv[2] || "[email protected]";
|
||||
const db = getDb();
|
||||
const user = db.select().from(users).where(eq(users.email, email)).get();
|
||||
if (!user) {
|
||||
console.error("User not found:", email);
|
||||
process.exit(1);
|
||||
}
|
||||
const g = generateApiToken();
|
||||
db.insert(apiTokens)
|
||||
.values({
|
||||
id: crypto.randomUUID(),
|
||||
userId: user.id,
|
||||
name: "smoke",
|
||||
tokenHash: g.tokenHash,
|
||||
prefix: g.prefix,
|
||||
expiresAt: null,
|
||||
lastUsedAt: null,
|
||||
createdAt: new Date(),
|
||||
})
|
||||
.run();
|
||||
console.log(g.token);
|
||||
resetDbConnection();
|
||||
Reference in New Issue
Block a user