fix: return all user data in auth endpoints and add mock data to seed users
Build and Deploy (Gitea) / build-and-deploy (push) Successful in 46s Details

This commit is contained in:
Sidney Gomes 2026-07-21 20:04:11 -03:00
parent 3d0420b006
commit 647338fe75
3 changed files with 28 additions and 4 deletions

View File

@ -117,7 +117,11 @@ app.post('/api/auth/register', async (req: Request, res: Response) => {
name: newUser.name,
email: newUser.email,
role: newUser.role,
subscriptionStatus: newUser.subscriptionStatus
subscriptionStatus: newUser.subscriptionStatus,
cpf: newUser.cpf,
whatsapp: newUser.whatsapp,
birthDate: newUser.birthDate,
createdAt: newUser.createdAt
}
});
} catch (err: any) {
@ -162,7 +166,11 @@ app.post('/api/auth/login', (req: Request, res: Response) => {
email: user.email,
role: user.role,
subscriptionStatus: user.subscriptionStatus,
unlockedCourses: user.unlockedCourses || []
unlockedCourses: user.unlockedCourses || [],
cpf: user.cpf,
whatsapp: user.whatsapp,
birthDate: user.birthDate,
createdAt: user.createdAt
}
});
});
@ -188,7 +196,11 @@ app.get('/api/auth/me', authenticateToken, (req: AuthenticatedRequest, res: Resp
email: user.email,
role: user.role,
subscriptionStatus: user.subscriptionStatus,
unlockedCourses: user.unlockedCourses || []
unlockedCourses: user.unlockedCourses || [],
cpf: user.cpf,
whatsapp: user.whatsapp,
birthDate: user.birthDate,
createdAt: user.createdAt
});
});

View File

@ -90,7 +90,7 @@ export default function ProfileView({ user, onBack }: ProfileViewProps) {
<div>
<p className="text-[10px] uppercase font-bold text-zinc-500">Membro desde</p>
<p className="text-sm font-medium text-white">
{new Date(user.createdAt).toLocaleDateString('pt-BR')}
{user.createdAt ? new Date(user.createdAt).toLocaleDateString('pt-BR') : 'Não disponível'}
</p>
</div>
</div>

View File

@ -87,6 +87,8 @@ function createInitialDb(): DatabaseSchema {
subscriptionStatus: 'ACTIVE',
asaasCustomerId: null,
cpf: '691.238.910-40',
whatsapp: '11999999999',
birthDate: '1989-05-15',
unlockedCourses: [],
createdAt: now
},
@ -99,6 +101,8 @@ function createInitialDb(): DatabaseSchema {
subscriptionStatus: 'ACTIVE',
asaasCustomerId: 'cus_00001',
cpf: '691.238.910-40',
whatsapp: '11999999999',
birthDate: '1989-05-15',
unlockedCourses: ['crs_excel'], // Excel starts unlocked for Joao
createdAt: new Date(Date.now() - 30 * 24 * 3600 * 1000).toISOString()
},
@ -111,6 +115,8 @@ function createInitialDb(): DatabaseSchema {
subscriptionStatus: 'ACTIVE',
asaasCustomerId: 'cus_00002',
cpf: '691.238.910-40',
whatsapp: '11999999999',
birthDate: '1989-05-15',
unlockedCourses: [],
createdAt: new Date(Date.now() - 15 * 24 * 3600 * 1000).toISOString()
},
@ -123,6 +129,8 @@ function createInitialDb(): DatabaseSchema {
subscriptionStatus: 'OVERDUE',
asaasCustomerId: 'cus_00003',
cpf: '691.238.910-40',
whatsapp: '11999999999',
birthDate: '1989-05-15',
unlockedCourses: [],
createdAt: new Date(Date.now() - 45 * 24 * 3600 * 1000).toISOString()
},
@ -135,6 +143,8 @@ function createInitialDb(): DatabaseSchema {
subscriptionStatus: 'CANCELED',
asaasCustomerId: 'cus_00004',
cpf: '691.238.910-40',
whatsapp: '11999999999',
birthDate: '1989-05-15',
unlockedCourses: [],
createdAt: new Date(Date.now() - 60 * 24 * 3600 * 1000).toISOString()
},
@ -147,6 +157,8 @@ function createInitialDb(): DatabaseSchema {
subscriptionStatus: 'ACTIVE',
asaasCustomerId: 'cus_test',
cpf: '691.238.910-40',
whatsapp: '11999999999',
birthDate: '1989-05-15',
unlockedCourses: [], // Starts with only the free courses unlocked
createdAt: now
}