mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-24 09:03:11 +00:00
fix(RS+): depth:0 sem select parcial; form schema de convite separado
Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
This commit is contained in:
parent
7484aab28a
commit
104d6d4589
5 changed files with 10 additions and 17 deletions
|
|
@ -12,7 +12,7 @@ import {
|
||||||
requiredFormSecret,
|
requiredFormSecret,
|
||||||
requiredFormText,
|
requiredFormText,
|
||||||
} from '@/lib/formData'
|
} from '@/lib/formData'
|
||||||
import { campaignInviteAutofillSchema, campaignInviteLoginSchema } from '@/lib/schemas/invite'
|
import { campaignInviteAutofillSchema, campaignInviteLoginFormSchema } from '@/lib/schemas/invite'
|
||||||
import {
|
import {
|
||||||
mapCampaignFormActionError,
|
mapCampaignFormActionError,
|
||||||
runCampaignFormAction,
|
runCampaignFormAction,
|
||||||
|
|
@ -68,7 +68,7 @@ export const redeemCampaignInviteLoginFormAction = async (
|
||||||
formData: FormData,
|
formData: FormData,
|
||||||
): Promise<CampaignInviteFormState> => {
|
): Promise<CampaignInviteFormState> => {
|
||||||
try {
|
try {
|
||||||
const input = campaignInviteLoginSchema.parse({
|
const input = campaignInviteLoginFormSchema.parse({
|
||||||
token,
|
token,
|
||||||
...profileFromForm(formData),
|
...profileFromForm(formData),
|
||||||
password: requiredFormSecret(formData, 'password'),
|
password: requiredFormSecret(formData, 'password'),
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import { CampaignAuthCardHeader } from '@/components/campaign/auth/CampaignAuthC
|
||||||
import { CampaignPasswordFields } from '@/components/campaign/auth/CampaignPasswordFields'
|
import { CampaignPasswordFields } from '@/components/campaign/auth/CampaignPasswordFields'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
import { Card, CardContent } from '@/components/ui/card'
|
import { Card, CardContent } from '@/components/ui/card'
|
||||||
import { Field, FieldError, FieldGroup } from '@/components/ui/field'
|
import { FieldError, FieldGroup } from '@/components/ui/field'
|
||||||
import { Spinner } from '@/components/ui/Spinner'
|
import { Spinner } from '@/components/ui/Spinner'
|
||||||
import type { CampaignFormActionState } from '@/utilities/campaignFormActionError'
|
import type { CampaignFormActionState } from '@/utilities/campaignFormActionError'
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,14 @@ export const campaignInviteAutofillSchema = campaignInviteProfileSchema.extend({
|
||||||
consentAccepted: z.boolean().optional(),
|
consentAccepted: z.boolean().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
export const campaignInviteLoginSchema = campaignInviteProfileSchema
|
export const campaignInviteLoginSchema = campaignInviteProfileSchema.extend({
|
||||||
|
password: campaignPasswordSchema,
|
||||||
|
consentAccepted: z.boolean().optional(),
|
||||||
|
})
|
||||||
|
|
||||||
|
export const campaignInviteLoginFormSchema = campaignInviteLoginSchema
|
||||||
.extend({
|
.extend({
|
||||||
password: campaignPasswordSchema,
|
|
||||||
passwordConfirmation: campaignPasswordSchema,
|
passwordConfirmation: campaignPasswordSchema,
|
||||||
consentAccepted: z.boolean().optional(),
|
|
||||||
})
|
})
|
||||||
.superRefine(refineMatchingPasswords)
|
.superRefine(refineMatchingPasswords)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ type CampaignAuthPayload = Pick<Payload, 'auth' | 'findByID'>
|
||||||
type CampaignCookiePayload = Pick<Payload, 'secret'>
|
type CampaignCookiePayload = Pick<Payload, 'secret'>
|
||||||
export type AuthenticatedCampaignUser = CampaignUser & { email: string }
|
export type AuthenticatedCampaignUser = CampaignUser & { email: string }
|
||||||
|
|
||||||
/** Gate reload — no `media` join; avatar stays a bare relationship id. */
|
/** Gate reload fields — kept as documentation for future partial selects. */
|
||||||
export const CAMPAIGN_AUTH_GATE_SELECT = {
|
export const CAMPAIGN_AUTH_GATE_SELECT = {
|
||||||
id: true,
|
id: true,
|
||||||
name: true,
|
name: true,
|
||||||
|
|
@ -108,7 +108,6 @@ export const authenticateCampaignToken = async (
|
||||||
collection: 'campaignUser',
|
collection: 'campaignUser',
|
||||||
id: user.id,
|
id: user.id,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
select: CAMPAIGN_AUTH_GATE_SELECT,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
@ -138,7 +137,6 @@ const readAuthenticatedCampaignUser = async (
|
||||||
collection: 'campaignUser',
|
collection: 'campaignUser',
|
||||||
id: user.id,
|
id: user.id,
|
||||||
depth: 1,
|
depth: 1,
|
||||||
select: CAMPAIGN_AUTH_GATE_SELECT,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
|
|
@ -181,14 +181,6 @@ describe('campaign authentication foundation', () => {
|
||||||
collection: 'campaignUser',
|
collection: 'campaignUser',
|
||||||
id: staleJwtUser.id,
|
id: staleJwtUser.id,
|
||||||
depth: 0,
|
depth: 0,
|
||||||
select: expect.objectContaining({
|
|
||||||
id: true,
|
|
||||||
name: true,
|
|
||||||
role: true,
|
|
||||||
email: true,
|
|
||||||
username: true,
|
|
||||||
avatar: true,
|
|
||||||
}),
|
|
||||||
})
|
})
|
||||||
expect(result?.email).toBe('')
|
expect(result?.email).toBe('')
|
||||||
expect(result?.role).toBe('advisor')
|
expect(result?.role).toBe('advisor')
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue