ФУНКЦИИ - NODEDC LAUNCHER: управление пользователями платформы

This commit is contained in:
DCCONSTRUCTIONS
2026-05-11 12:20:46 +03:00
parent 8be33c53da
commit 2b34cf9f1b
9 changed files with 1130 additions and 245 deletions
+26
View File
@@ -67,6 +67,31 @@ export function createAuthentikSyncClient({ baseUrl, token }) {
};
}
async function deleteUser({ data, userId }) {
ensureConfigured();
const user = findById(data.users, userId, "user");
const existingUser = await findUserByIdOrEmail(user.authentikUserId, user.email);
if (!existingUser) {
return {
deleted: false,
email: user.email,
authentikUserId: user.authentikUserId ?? null,
authentikPk: null,
};
}
await requestJson(`/api/v3/core/users/${encodeURIComponent(existingUser.pk)}/`, { method: "DELETE" });
return {
deleted: true,
email: user.email,
authentikUserId: user.authentikUserId ?? null,
authentikPk: existingUser.pk,
};
}
async function findUserByIdOrEmail(authentikUserId, email) {
if (authentikUserId) {
const payload = await requestJson(`/api/v3/core/users/?search=${encodeURIComponent(authentikUserId)}`);
@@ -155,6 +180,7 @@ export function createAuthentikSyncClient({ baseUrl, token }) {
}
return {
deleteUser,
isConfigured,
provisionUser,
};