Merged in feat/masked-values (pull request #489)
feat: handle masked values only based on MFA Approved-by: Michael Zetterberg Approved-by: Arvid Norlin
This commit is contained in:
@@ -10,7 +10,7 @@ export default async function EditProfileSlot({
|
||||
}: PageArgs<LangParams>) {
|
||||
setLang(params.lang)
|
||||
|
||||
const user = await serverClient().user.get({ mask: false })
|
||||
const user = await serverClient().user.get()
|
||||
if (!user || "error" in user) {
|
||||
return null
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user