This commit is contained in:
seb
2026-06-23 11:04:07 +02:00
commit 667f498573
19 changed files with 4299 additions and 0 deletions

34
src/db/googleAuth.js Normal file
View File

@@ -0,0 +1,34 @@
import { getDb } from './client.js';
export function listAllowedEmails() {
return getDb()
.prepare('SELECT id, email, created_at FROM google_auth ORDER BY email COLLATE NOCASE')
.all();
}
export function getAllowedEmail(email) {
return getDb()
.prepare('SELECT id, email, created_at FROM google_auth WHERE email = ? COLLATE NOCASE')
.get(email);
}
export function getAllowedEmailById(id) {
return getDb()
.prepare('SELECT id, email, created_at FROM google_auth WHERE id = ?')
.get(id);
}
export function addAllowedEmail(email) {
const normalized = email.trim().toLowerCase();
const result = getDb()
.prepare('INSERT INTO google_auth (email) VALUES (?)')
.run(normalized);
return getAllowedEmailById(result.lastInsertRowid);
}
export function removeAllowedEmail(email) {
const normalized = email.trim().toLowerCase();
return getDb()
.prepare('DELETE FROM google_auth WHERE email = ? COLLATE NOCASE')
.run(normalized).changes > 0;
}