working leantime delete user 3

This commit is contained in:
Alma 2025-04-12 12:07:05 +02:00
parent e6deb9238f
commit 327035c153

View File

@ -5,32 +5,7 @@ import { NextResponse } from "next/server";
// Helper function to get Leantime user ID by email
async function getLeantimeUserId(email: string): Promise<number | null> {
try {
const response = await fetch('https://agilite.slm-lab.net/api/jsonrpc', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-Key': process.env.LEANTIME_TOKEN || '',
},
body: JSON.stringify({
method: 'leantime.rpc.Users.Users.usernameExist',
jsonrpc: '2.0',
id: 1,
params: {
username: email,
notUserId: 0
}
})
});
const data = await response.json();
console.log('Leantime username check response:', data);
if (!response.ok || !data.result) {
console.error('Failed to check Leantime user:', data);
return null;
}
// If user exists, get their ID
// Get user directly by email
const userResponse = await fetch('https://agilite.slm-lab.net/api/jsonrpc', {
method: 'POST',
headers: {