mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-25 01:15:26 +10:00
v5.1.0 (#2970)
* chore(release): v5.1.0 * feat: implement resume thumbnails * fix: remove unused mcp tools * docs: fix formatting of docs
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
import type { AuthProvider } from "@reactive-resume/auth/types";
|
||||
import { ORPCError } from "@orpc/client";
|
||||
import { eq } from "drizzle-orm";
|
||||
import { db } from "@reactive-resume/db/client";
|
||||
import * as schema from "@reactive-resume/db/schema";
|
||||
import { env } from "@reactive-resume/env/server";
|
||||
import { getStorageService } from "./storage";
|
||||
|
||||
export type ProviderList = Partial<Record<AuthProvider, string>>;
|
||||
|
||||
const providers = {
|
||||
list: (): ProviderList => {
|
||||
const providers: ProviderList = { credential: "Password", passkey: "Passkey" };
|
||||
|
||||
if (env.GOOGLE_CLIENT_ID && env.GOOGLE_CLIENT_SECRET) providers.google = "Google";
|
||||
if (env.GITHUB_CLIENT_ID && env.GITHUB_CLIENT_SECRET) providers.github = "GitHub";
|
||||
if (env.LINKEDIN_CLIENT_ID && env.LINKEDIN_CLIENT_SECRET) providers.linkedin = "LinkedIn";
|
||||
if (env.OAUTH_CLIENT_ID && env.OAUTH_CLIENT_SECRET) providers.custom = env.OAUTH_PROVIDER_NAME ?? "Custom OAuth";
|
||||
|
||||
return providers;
|
||||
},
|
||||
};
|
||||
|
||||
export const authService = {
|
||||
providers,
|
||||
|
||||
deleteAccount: async (input: { userId: string }): Promise<void> => {
|
||||
if (!input.userId || input.userId.length === 0) return;
|
||||
|
||||
const storageService = getStorageService();
|
||||
|
||||
// Delete all user files in one call (pictures, screenshots, pdfs)
|
||||
// The storage service delete method supports recursive deletion via prefix
|
||||
try {
|
||||
await storageService.delete(`uploads/${input.userId}`);
|
||||
} catch {
|
||||
// Ignore error and proceed with deleting user
|
||||
}
|
||||
|
||||
try {
|
||||
await db.delete(schema.user).where(eq(schema.user.id, input.userId));
|
||||
} catch (err) {
|
||||
console.error("Failed to delete user record:", err);
|
||||
|
||||
throw new ORPCError("INTERNAL_SERVER_ERROR");
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user