delete user leantime api 12

This commit is contained in:
Alma 2025-04-10 22:23:27 +02:00
parent 42884c2934
commit 0865260a78

View File

@ -209,15 +209,6 @@ async function createLeantimeUser(userData: {
roles: string[]; roles: string[];
}): Promise<{ success: boolean; error?: string }> { }): Promise<{ success: boolean; error?: string }> {
try { try {
// Map Keycloak roles to Leantime roles
const getLeantimeRole = (roles: string[]) => {
if (roles.includes('admin')) return 'admin';
if (roles.includes('teacher')) return 'manager';
return 'user';
};
const leantimeRole = getLeantimeRole(userData.roles);
const response = await fetch('https://agilite.slm-lab.net/api/jsonrpc', { const response = await fetch('https://agilite.slm-lab.net/api/jsonrpc', {
method: 'POST', method: 'POST',
headers: { headers: {
@ -233,7 +224,7 @@ async function createLeantimeUser(userData: {
'0': 0, // This will be set by Leantime '0': 0, // This will be set by Leantime
'1': userData.lastName, '1': userData.lastName,
'2': userData.firstName, '2': userData.firstName,
'3': leantimeRole, '3': '20', // Default role
'4': '', // profileId '4': '', // profileId
'5': 'a', // status '5': 'a', // status
'6': userData.email, '6': userData.email,
@ -246,7 +237,7 @@ async function createLeantimeUser(userData: {
'13': new Date().toISOString(), // modified '13': new Date().toISOString(), // modified
lastname: userData.lastName, lastname: userData.lastName,
firstname: userData.firstName, firstname: userData.firstName,
role: leantimeRole, role: '20', // Default role
profileId: '', profileId: '',
status: 'a', status: 'a',
username: userData.email, username: userData.email,
@ -257,7 +248,11 @@ async function createLeantimeUser(userData: {
jobTitle: '', jobTitle: '',
jobLevel: '', jobLevel: '',
department: '', department: '',
modified: new Date().toISOString() modified: new Date().toISOString(),
createdOn: new Date().toISOString(),
source: 'keycloak',
notifications: 1,
settings: '{}'
} }
} }
}) })