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:
@@ -54,46 +54,21 @@ export const userQueryRouter = router({
|
|||||||
|
|
||||||
return parsedUser(data.data, ctx.isMFA)
|
return parsedUser(data.data, ctx.isMFA)
|
||||||
}),
|
}),
|
||||||
getSafely: safeProtectedProcedure
|
getSafely: safeProtectedProcedure.query(async function getUser({ ctx }) {
|
||||||
.use(async function (opts) {
|
if (!isValidSession(ctx.session)) {
|
||||||
return opts.next({
|
return null
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await getVerifiedUser({ session: ctx.session })
|
const data = await getVerifiedUser({ session: ctx.session })
|
||||||
|
|
||||||
if (!data || "error" in data) {
|
if (!data || "error" in data) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedUser(data.data, ctx.isMFA)
|
return parsedUser(data.data, true)
|
||||||
}),
|
}),
|
||||||
getWithExtendedPartnerData: safeProtectedProcedure
|
getWithExtendedPartnerData: safeProtectedProcedure.query(
|
||||||
.use(async function (opts) {
|
async function getUser({ ctx }) {
|
||||||
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)) {
|
if (!isValidSession(ctx.session)) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
@@ -107,8 +82,9 @@ export const userQueryRouter = router({
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return parsedUser(data.data, ctx.isMFA)
|
return parsedUser(data.data, true)
|
||||||
}),
|
}
|
||||||
|
),
|
||||||
name: safeProtectedProcedure.query(async function ({ ctx }) {
|
name: safeProtectedProcedure.query(async function ({ ctx }) {
|
||||||
if (!isValidSession(ctx.session)) {
|
if (!isValidSession(ctx.session)) {
|
||||||
return null
|
return null
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { getFriendsMembership } from "../helpers"
|
|||||||
|
|
||||||
import type { User } from "../../../types/user"
|
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 country = countries.find((c) => c.code === data.address?.countryCode)
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
@@ -31,7 +31,7 @@ export function parsedUser(data: User, isMFA: boolean) {
|
|||||||
promotions: data.promotions || null,
|
promotions: data.promotions || null,
|
||||||
} satisfies User
|
} satisfies User
|
||||||
|
|
||||||
if (!isMFA) {
|
if (maskValues) {
|
||||||
if (user.address.city) {
|
if (user.address.city) {
|
||||||
user.address.city = maskValue.text(user.address.city)
|
user.address.city = maskValue.text(user.address.city)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user