fix(avatar): sincroniza avatar apos atualizar
All checks were successful
All checks were successful
- Propaga Set-Cookie do Better Auth no endpoint de avatar\n- Forca refresh da sessao apos upload/remocao\n- Adiciona teste de propagacao e defaults de env para testes
This commit is contained in:
parent
74c06ffa33
commit
8546a1feb1
6 changed files with 84 additions and 4 deletions
|
|
@ -4,7 +4,7 @@
|
|||
* DELETE - Remove a foto de perfil (volta ao padrão)
|
||||
*/
|
||||
|
||||
import { NextRequest, NextResponse } from "next/server"
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
import { getServerSession } from "@/lib/auth-server"
|
||||
import { auth } from "@/lib/auth"
|
||||
|
|
@ -34,7 +34,7 @@ function extractSetCookies(headers: Headers) {
|
|||
return setCookieHeaders
|
||||
}
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
export async function POST(request: Request) {
|
||||
try {
|
||||
const session = await getServerSession()
|
||||
|
||||
|
|
@ -142,7 +142,7 @@ export async function POST(request: NextRequest) {
|
|||
}
|
||||
}
|
||||
|
||||
export async function DELETE(request: NextRequest) {
|
||||
export async function DELETE(request: Request) {
|
||||
try {
|
||||
const session = await getServerSession()
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle }
|
|||
import { Input } from "@/components/ui/input"
|
||||
import { Label } from "@/components/ui/label"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { useAuth, signOut } from "@/lib/auth-client"
|
||||
import { refreshSession, signOut, useAuth } from "@/lib/auth-client"
|
||||
|
||||
const ShaderBackground = dynamic(
|
||||
() => import("@/components/background-paper-shaders-wrapper"),
|
||||
|
|
@ -442,6 +442,7 @@ function ProfileEditCard({
|
|||
|
||||
const avatarData = await avatarRes.json()
|
||||
setLocalAvatarUrl(avatarData.avatarUrl)
|
||||
await refreshSession()
|
||||
|
||||
// Limpa preview
|
||||
if (pendingAvatarPreview) {
|
||||
|
|
@ -461,6 +462,7 @@ function ProfileEditCard({
|
|||
|
||||
setLocalAvatarUrl(null)
|
||||
setPendingRemoveAvatar(false)
|
||||
await refreshSession()
|
||||
}
|
||||
|
||||
// Processa outros dados do perfil se houver
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue