correction flow 7

This commit is contained in:
Alma 2025-04-12 10:31:54 +02:00
parent 94e8e89717
commit 36046ab35b
2 changed files with 8 additions and 5 deletions

2
.env
View File

@ -42,5 +42,5 @@ NEXT_PUBLIC_IFRAME_AI_ASSISTANT_URL=https://alma.slm-lab.net
ROCKET_CHAT_TOKEN=w91TYgkH-Z67Oz72usYdkW5TZLLRwnre7qyAhp7aHJB
ROCKET_CHAT_USER_ID=Tpuww59PJKsrGNQJB
LEANTIME_API_KEY=lt_lsdShQdoYHaPUWuL07XZR1Rf3GeySsIs_UDlll3VJPk5EwAuILpMC4BwzJ9MZFRrb
LEANTIME_TOKEN=lt_lsdShQdoYHaPUWuL07XZR1Rf3GeySsIs_UDlll3VJPk5EwAuILpMC4BwzJ9MZFRrb
LEANTIME_API_URL=https://agilite.slm-lab.net

View File

@ -206,13 +206,15 @@ async function createLeantimeUser(userData: {
firstName: string;
lastName: string;
email: string;
password: string;
}): Promise<{ success: boolean; error?: string }> {
try {
const response = await fetch('https://agilite.slm-lab.net/index.php/api/jsonrpc', {
const response = await fetch('https://agilite.slm-lab.net/api/jsonrpc', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': process.env.LEANTIME_API_KEY!,
'Authorization': `Bearer ${process.env.LEANTIME_TOKEN}`,
'X-API-Key': process.env.LEANTIME_TOKEN || '',
},
body: JSON.stringify({
method: 'leantime.rpc.Users.Users.addUser',
@ -224,9 +226,9 @@ async function createLeantimeUser(userData: {
lastname: userData.lastName,
username: userData.username,
email: userData.email,
password: userData.password,
status: 'active',
role: 'user', // Default role in Leantime
password: Math.random().toString(36).slice(-8), // Generate a random password
source: 'keycloak',
}
}
@ -240,7 +242,7 @@ async function createLeantimeUser(userData: {
console.error('Leantime user creation failed:', data);
return {
success: false,
error: 'Failed to create user in Leantime'
error: data.error?.message || 'Failed to create user in Leantime'
};
}
@ -416,6 +418,7 @@ export async function POST(req: Request) {
firstName: data.firstName,
lastName: data.lastName,
email: data.email,
password: data.password,
});
if (!leantimeResult.success) {