ФУНКЦИИ - NODEDC LAUNCHER: управление пользователями платформы
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user