add markUserAndProfileEmailVerified
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
import * as schema from '@db/schema';
|
import * as schema from '@db/schema';
|
||||||
|
|
||||||
import type { TProfile } from '@db/types';
|
import type { TProfile } from '@db/types';
|
||||||
import { db } from '@db/drizzle';
|
import { db, type DbOrTxClient } from '@db/drizzle';
|
||||||
import { eq } from 'drizzle-orm';
|
import { eq } from 'drizzle-orm';
|
||||||
|
|
||||||
export const getProfileById = async (id: string) => {
|
export const getProfileById = async (id: string) => {
|
||||||
@@ -21,3 +21,13 @@ export const updateProfile = async (id: string, data: Partial<Omit<TProfile, 'id
|
|||||||
|
|
||||||
return updatedProfile;
|
return updatedProfile;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const markUserAndProfileEmailVerified = async (userId: string, dbClient: DbOrTxClient = db) => {
|
||||||
|
const verifiedAt = new Date().toISOString();
|
||||||
|
|
||||||
|
await dbClient.update(schema.user).set({ emailVerified: true }).where(eq(schema.user.id, userId));
|
||||||
|
await dbClient
|
||||||
|
.update(schema.profile)
|
||||||
|
.set({ isEmailVerified: true, verifiedAt })
|
||||||
|
.where(eq(schema.profile.id, userId));
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user