mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2026-07-25 09:24:54 +10:00
📦 v5.0.7 - Changelog: https://docs.rxresu.me/changelog (#2696)
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { ORPCError } from "@orpc/client";
|
||||
import { and, eq, isNotNull } from "drizzle-orm";
|
||||
import { eq } from "drizzle-orm";
|
||||
import type { AuthProvider } from "@/integrations/auth/types";
|
||||
import { schema } from "@/integrations/drizzle";
|
||||
import { db } from "@/integrations/drizzle/client";
|
||||
import { env } from "@/utils/env";
|
||||
import { verifyPassword } from "@/utils/password";
|
||||
import { grantResumeAccess } from "../helpers/resume-access";
|
||||
import { getStorageService } from "./storage";
|
||||
|
||||
export type ProviderList = Partial<Record<AuthProvider, string>>;
|
||||
@@ -25,31 +23,6 @@ const providers = {
|
||||
export const authService = {
|
||||
providers,
|
||||
|
||||
verifyResumePassword: async (input: { slug: string; username: string; password: string }): Promise<boolean> => {
|
||||
const [resume] = await db
|
||||
.select({ id: schema.resume.id, password: schema.resume.password })
|
||||
.from(schema.resume)
|
||||
.innerJoin(schema.user, eq(schema.resume.userId, schema.user.id))
|
||||
.where(
|
||||
and(
|
||||
isNotNull(schema.resume.password),
|
||||
eq(schema.resume.slug, input.slug),
|
||||
eq(schema.user.username, input.username),
|
||||
),
|
||||
);
|
||||
|
||||
if (!resume) throw new ORPCError("NOT_FOUND");
|
||||
|
||||
const passwordHash = resume.password as string;
|
||||
const isValid = await verifyPassword(input.password, passwordHash);
|
||||
|
||||
if (!isValid) throw new ORPCError("INVALID_PASSWORD");
|
||||
|
||||
grantResumeAccess(resume.id, passwordHash);
|
||||
|
||||
return true;
|
||||
},
|
||||
|
||||
deleteAccount: async (input: { userId: string }): Promise<void> => {
|
||||
if (!input.userId || input.userId.length === 0) return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user