Updates
This commit is contained in:
@@ -73,7 +73,7 @@ export default async function handler(
|
||||
email,
|
||||
password: new_user_password,
|
||||
is_super_admin: user?.id ? 0 : 1,
|
||||
username: slugify(username),
|
||||
username: username ? slugify(username) : undefined,
|
||||
},
|
||||
],
|
||||
table: "users",
|
||||
@@ -90,20 +90,31 @@ export default async function handler(
|
||||
(typeof NSQLiteTables)[number]
|
||||
>({
|
||||
table: "users",
|
||||
query: {
|
||||
query: {
|
||||
is_super_admin: { value: "1" },
|
||||
},
|
||||
},
|
||||
targetId: new_user_id,
|
||||
});
|
||||
|
||||
const newly_inserted_user = newly_inserted_user_res.singleRes;
|
||||
|
||||
if (!newly_inserted_user?.id) {
|
||||
console.log("newly_inserted_user_res", newly_inserted_user_res);
|
||||
throw new Error(`Couldn't Find Newly inserted user.`);
|
||||
}
|
||||
|
||||
if (user?.id && !newly_inserted_user.username) {
|
||||
const newly_inserted_user_res = await NSQLite.delete<
|
||||
NSQLITE_TURBOCI_ADMIN_USERS,
|
||||
(typeof NSQLiteTables)[number]
|
||||
>({
|
||||
table: "users",
|
||||
targetId: newly_inserted_user?.id,
|
||||
});
|
||||
|
||||
throw new Error(`Couldn't set Newly inserted user username.`);
|
||||
}
|
||||
|
||||
if (user?.id) {
|
||||
console.log("newly_inserted_user", newly_inserted_user);
|
||||
|
||||
await setupDeploymentUser({ user_id: newly_inserted_user.id });
|
||||
|
||||
return res.json({
|
||||
|
||||
Reference in New Issue
Block a user