u
This commit is contained in:
21
src/db/company.js
Normal file
21
src/db/company.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import { getStore } from './store.js';
|
||||
|
||||
export async function listCompanies(authId) {
|
||||
const store = await getStore();
|
||||
return store.company.list(authId);
|
||||
}
|
||||
|
||||
export async function createCompany(authId, data) {
|
||||
const store = await getStore();
|
||||
return store.company.create({ ...data, authId });
|
||||
}
|
||||
|
||||
export async function updateCompany(id, data) {
|
||||
const store = await getStore();
|
||||
return store.company.update(id, data);
|
||||
}
|
||||
|
||||
export async function deleteCompany(companyId) {
|
||||
const store = await getStore();
|
||||
await store.company.delete(companyId);
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import { getStore } from './store.js';
|
||||
|
||||
export async function listAllowedEmails() {
|
||||
const store = await getStore();
|
||||
return store.google_auth.list();
|
||||
return store.google_auth.listAllowedEmails();
|
||||
}
|
||||
|
||||
export async function getAllowedEmail(email) {
|
||||
@@ -19,9 +19,15 @@ export async function addAllowedEmail(email) {
|
||||
}
|
||||
|
||||
export async function removeAllowedEmail(email) {
|
||||
const row = await getAllowedEmail(email);
|
||||
const normalized = email.trim().toLowerCase();
|
||||
const row = await getAllowedEmail(normalized);
|
||||
if (!row) return false;
|
||||
const store = await getStore();
|
||||
await store.google_auth.del(row.id);
|
||||
await store.google_auth.removeAllowedEmail(normalized);
|
||||
return true;
|
||||
}
|
||||
|
||||
export async function setSelectedCompany(authId, companyId) {
|
||||
const store = await getStore();
|
||||
await store.google_auth.setSelectedCompany(authId, companyId);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user