mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:35:25 +02:00
feat: implement manual user validation and user deletion flow
This commit is contained in:
@@ -40,6 +40,31 @@ export async function signIn(email: string, password: string): Promise<AuthSessi
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
// Validate status before signing in
|
||||
try {
|
||||
const statusRes = await fetch('/api/users-admin', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${data.access_token}`
|
||||
},
|
||||
body: JSON.stringify({ action: 'check-status' })
|
||||
});
|
||||
|
||||
if (!statusRes.ok) {
|
||||
const err = await statusRes.json().catch(() => ({}));
|
||||
throw new Error(err.error || 'Failed to verify account validation status.');
|
||||
}
|
||||
|
||||
const statusData = await statusRes.json();
|
||||
if (!statusData.validated) {
|
||||
throw new Error('Tu usuario aún no ha sido validado por un administrador.');
|
||||
}
|
||||
} catch (err: any) {
|
||||
throw new Error(err.message || 'Error de validación del usuario.');
|
||||
}
|
||||
|
||||
const session: AuthSession = {
|
||||
access_token: data.access_token,
|
||||
refresh_token: data.refresh_token,
|
||||
|
||||
Reference in New Issue
Block a user