Merged in fix/getProfile (pull request #2950)

Fix/getProfile

* fix(mypages): do not fetch SAS data on overview page and use correct mfa value when masking personal data

* Merge branch 'master' into fix/getProfile

* feat(profile): revert and dont mask data :O


Approved-by: Anton Gunnarsson
This commit is contained in:
Linus Flood
2025-10-10 10:42:23 +00:00
parent ddbc4a063d
commit 1668baf04b
2 changed files with 17 additions and 41 deletions

View File

@@ -54,46 +54,21 @@ export const userQueryRouter = router({
return parsedUser(data.data, ctx.isMFA)
}),
getSafely: safeProtectedProcedure
.use(async function (opts) {
return opts.next({
ctx: {
...opts.ctx,
isMFA:
!!opts.ctx.session &&
!!opts.ctx.session.token.mfa_scope &&
!!opts.ctx.session.token.mfa_expires_at &&
opts.ctx.session.token.mfa_expires_at > Date.now(),
},
})
})
.query(async function getUser({ ctx }) {
if (!isValidSession(ctx.session)) {
return null
}
getSafely: safeProtectedProcedure.query(async function getUser({ ctx }) {
if (!isValidSession(ctx.session)) {
return null
}
const data = await getVerifiedUser({ session: ctx.session })
const data = await getVerifiedUser({ session: ctx.session })
if (!data || "error" in data) {
return null
}
if (!data || "error" in data) {
return null
}
return parsedUser(data.data, ctx.isMFA)
}),
getWithExtendedPartnerData: safeProtectedProcedure
.use(async function (opts) {
return opts.next({
ctx: {
...opts.ctx,
isMFA:
!!opts.ctx.session &&
!!opts.ctx.session.token.mfa_scope &&
!!opts.ctx.session.token.mfa_expires_at &&
opts.ctx.session.token.mfa_expires_at > Date.now(),
},
})
})
.query(async function getUser({ ctx }) {
return parsedUser(data.data, true)
}),
getWithExtendedPartnerData: safeProtectedProcedure.query(
async function getUser({ ctx }) {
if (!isValidSession(ctx.session)) {
return null
}
@@ -107,8 +82,9 @@ export const userQueryRouter = router({
return null
}
return parsedUser(data.data, ctx.isMFA)
}),
return parsedUser(data.data, true)
}
),
name: safeProtectedProcedure.query(async function ({ ctx }) {
if (!isValidSession(ctx.session)) {
return null

View File

@@ -5,7 +5,7 @@ import { getFriendsMembership } from "../helpers"
import type { User } from "../../../types/user"
export function parsedUser(data: User, isMFA: boolean) {
export function parsedUser(data: User, maskValues: boolean) {
const country = countries.find((c) => c.code === data.address?.countryCode)
const user = {
@@ -31,7 +31,7 @@ export function parsedUser(data: User, isMFA: boolean) {
promotions: data.promotions || null,
} satisfies User
if (!isMFA) {
if (maskValues) {
if (user.address.city) {
user.address.city = maskValue.text(user.address.city)
}