Implement auth for pocketbase

This commit is contained in:
2025-07-07 15:31:37 +02:00
parent 0ca4ca9eed
commit b199742dff
6 changed files with 15 additions and 7 deletions

1
.gitignore vendored
View File

@@ -1,3 +1,4 @@
build/bin
dist
node_modules
src/lib/pocketbaseAdmin.ts

View File

@@ -1,6 +1,15 @@
import PocketBase from 'pocketbase';
import { TypedPocketBase } from './pbtypes';
import { POCKETBASE_SUPERUSER_EMAIL, POCKETBASE_SUPERUSER_PASSWORD } from './pocketbaseAdmin';
const pb = new PocketBase('https://evebase.site.quack-lab.dev') as TypedPocketBase;
async function adminLogin() {
try {
await pb.collection('_superusers').authWithPassword(POCKETBASE_SUPERUSER_EMAIL, POCKETBASE_SUPERUSER_PASSWORD);
console.log('Admin logged in');
} catch (error) {
console.error('Admin login failed:', error);
}
}
export default pb;
export { pb, adminLogin };

View File

@@ -1,5 +1,5 @@
import { IndBillitemRecord, IndBillitemRecordNoId } from "@/lib/pbtypes";
import pb from "@/lib/pocketbase";
import { pb } from "@/lib/pocketbase";
export async function addBillItem(
jobId: string,

View File

@@ -1,5 +1,5 @@
import type { IndFacilityRecord, IndFacilityResponse } from '../lib/pbtypes';
import pb from '../lib/pocketbase';
import { pb } from '../lib/pocketbase';
export type { IndFacilityRecord as Facility } from '../lib/pbtypes';

View File

@@ -1,7 +1,6 @@
import { IndJob } from '@/lib/types';
import type { IndJobRecord, IndJobRecordNoId } from '../lib/pbtypes';
import pb from '../lib/pocketbase';
import { pb } from '../lib/pocketbase';
export type { IndJobRecord as Job } from '../lib/pbtypes';
export type { IndTransactionRecord as Transaction } from '../lib/pbtypes';

View File

@@ -1,7 +1,6 @@
import { IndJob } from '@/lib/types';
import type { IndTransactionRecord, IndTransactionRecordNoId } from '../lib/pbtypes';
import pb from '../lib/pocketbase';
import { pb } from '../lib/pocketbase';
import { updateJob } from './jobService';
export async function createTransaction(