diff --git a/app/[lang]/(live)/(protected)/my-pages/profile/@profile/edit/page.tsx b/app/[lang]/(live)/(protected)/my-pages/profile/@profile/edit/page.tsx index a86926356..1f40f50ca 100644 --- a/app/[lang]/(live)/(protected)/my-pages/profile/@profile/edit/page.tsx +++ b/app/[lang]/(live)/(protected)/my-pages/profile/@profile/edit/page.tsx @@ -10,7 +10,7 @@ export default async function EditProfileSlot({ }: PageArgs) { setLang(params.lang) - const user = await serverClient().user.get({ mask: false }) + const user = await serverClient().user.get() if (!user || "error" in user) { return null } diff --git a/server/routers/user/input.ts b/server/routers/user/input.ts index 98715cd0a..d84875ea3 100644 --- a/server/routers/user/input.ts +++ b/server/routers/user/input.ts @@ -1,12 +1,6 @@ import { z } from "zod" // Query -export const getUserInputSchema = z - .object({ - mask: z.boolean().default(true), - }) - .default({}) - export const staysInput = z .object({ cursor: z diff --git a/server/routers/user/query.ts b/server/routers/user/query.ts index e49bcb826..ef130e72b 100644 --- a/server/routers/user/query.ts +++ b/server/routers/user/query.ts @@ -12,11 +12,7 @@ import * as maskValue from "@/utils/maskValue" import { getMembership, getMembershipCards } from "@/utils/user" import encryptValue from "../utils/encryptValue" -import { - friendTransactionsInput, - getUserInputSchema, - staysInput, -} from "./input" +import { friendTransactionsInput, staysInput } from "./input" import { creditCardsSchema, FriendTransaction, @@ -192,8 +188,17 @@ async function updateStaysBookingUrl( export const userQueryRouter = router({ get: protectedProcedure - .input(getUserInputSchema) - .query(async function getUser({ ctx, input }) { + .use(async function (opts) { + return opts.next({ + ctx: { + ...opts.ctx, + isMFA: + opts.ctx.session.token.mfa_scope && + opts.ctx.session.token.mfa_expires_at > Date.now(), + }, + }) + }) + .query(async function getUser({ ctx }) { const data = await getVerifiedUser({ session: ctx.session }) if (!data) { @@ -230,7 +235,7 @@ export const userQueryRouter = router({ profileId: verifiedData.data.profileId, } - if (input.mask) { + if (!ctx.isMFA) { if (user.address.city) { user.address.city = maskValue.text(user.address.city) }