Implement auth for pocketbase
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,3 +1,4 @@
|
|||||||
build/bin
|
build/bin
|
||||||
dist
|
dist
|
||||||
node_modules
|
node_modules
|
||||||
|
src/lib/pocketbaseAdmin.ts
|
||||||
|
@@ -1,6 +1,15 @@
|
|||||||
import PocketBase from 'pocketbase';
|
import PocketBase from 'pocketbase';
|
||||||
import { TypedPocketBase } from './pbtypes';
|
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;
|
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 };
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import { IndBillitemRecord, IndBillitemRecordNoId } from "@/lib/pbtypes";
|
import { IndBillitemRecord, IndBillitemRecordNoId } from "@/lib/pbtypes";
|
||||||
import pb from "@/lib/pocketbase";
|
import { pb } from "@/lib/pocketbase";
|
||||||
|
|
||||||
export async function addBillItem(
|
export async function addBillItem(
|
||||||
jobId: string,
|
jobId: string,
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
import type { IndFacilityRecord, IndFacilityResponse } from '../lib/pbtypes';
|
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';
|
export type { IndFacilityRecord as Facility } from '../lib/pbtypes';
|
||||||
|
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import { IndJob } from '@/lib/types';
|
import { IndJob } from '@/lib/types';
|
||||||
import type { IndJobRecord, IndJobRecordNoId } from '../lib/pbtypes';
|
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 { IndJobRecord as Job } from '../lib/pbtypes';
|
||||||
export type { IndTransactionRecord as Transaction } from '../lib/pbtypes';
|
export type { IndTransactionRecord as Transaction } from '../lib/pbtypes';
|
||||||
|
@@ -1,7 +1,6 @@
|
|||||||
|
|
||||||
import { IndJob } from '@/lib/types';
|
import { IndJob } from '@/lib/types';
|
||||||
import type { IndTransactionRecord, IndTransactionRecordNoId } from '../lib/pbtypes';
|
import type { IndTransactionRecord, IndTransactionRecordNoId } from '../lib/pbtypes';
|
||||||
import pb from '../lib/pocketbase';
|
import { pb } from '../lib/pocketbase';
|
||||||
import { updateJob } from './jobService';
|
import { updateJob } from './jobService';
|
||||||
|
|
||||||
export async function createTransaction(
|
export async function createTransaction(
|
||||||
|
Reference in New Issue
Block a user