Añadida implementacion de resetear contraseña

This commit is contained in:
2025-11-29 19:11:33 -03:00
parent b60a2bb32f
commit 3068280b82
4 changed files with 160 additions and 7 deletions

View File

@@ -0,0 +1,24 @@
import { apiBase } from '@/stores/url';
import { get } from 'svelte/store';
import type { UserResponseDto } from '../../types';
import { sesionStore } from '@/stores/usuario';
export async function cambiarContraseña(usuario: UserResponseDto, newpass: string) {
try {
const req = await fetch(get(apiBase) + '/api/admin/password', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Authorization: `Bearer ${get(sesionStore)?.accessToken}`
},
body: JSON.stringify({ id: usuario.id, newpass })
});
if (req.ok) {
return '';
}
const data = await req.json();
return data.message;
} catch {
return 'No se pudo alcanzar el servidor';
}
}