Files
waseel/lib/auth.ts
Krikorios a0b297285a Add self-hosted auth, admin API, and owner web dashboard
- Replace Clerk with self-hosted JWT auth (register/login/verify, bcrypt
  passwords, Gmail OTP with console fallback)
- Add lib/db.ts pg pool + transaction helpers; seed script migrates legacy
  Clerk-era schema (drop clerk_id, enforce UUID ids and unique email)
- Add owner-gated admin API: stats, users, drivers CRUD, rides
- Add dashboard/ Vite React owner dashboard (login, overview, users,
  fleet, rides) with dev-server proxy to avoid Expo CORS middleware
- Add scripts/set-owner.mjs for role management
2026-08-23 16:38:41 +03:00

22 lines
578 B
TypeScript

import { fetchAPI } from "./fetch";
import type { SessionUser } from "./session";
export type AuthResult = {
token: string;
user: SessionUser;
};
// Exchanges a Google idToken (obtained via expo-auth-session on the client)
// for a Waseel session issued by our own server.
export const googleAuth = async (
idToken: string,
): Promise<AuthResult> => {
const response = await fetchAPI("/(api)/auth/google", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ idToken }),
});
return response.data as AuthResult;
};