Update login pipeline. Limit login to only password
This commit is contained in:
@@ -32,7 +32,12 @@ export default async function submitUserForm({
|
||||
const new_user_data: BUN_SQLITE_WGUI_USERS = _.pick<
|
||||
UserFormObject,
|
||||
keyof UserFormObject
|
||||
>(form, ["first_name", "last_name", "email", "username", "bio"]);
|
||||
>(
|
||||
form,
|
||||
is_first_user
|
||||
? ["first_name", "last_name", "email", "username", "password"]
|
||||
: ["first_name", "last_name", "email", "username", "bio"],
|
||||
);
|
||||
|
||||
setLoading(true);
|
||||
|
||||
@@ -40,7 +45,7 @@ export default async function submitUserForm({
|
||||
? await fetchApi<
|
||||
ApiReqParams,
|
||||
APIResponseObject<BUN_SQLITE_WGUI_USERS>
|
||||
>(`/api/create-first-user.ts`, {
|
||||
>(`/api/create-first-user`, {
|
||||
method: "POST",
|
||||
body: {
|
||||
insert_data: [new_user_data],
|
||||
@@ -86,8 +91,6 @@ export default async function submitUserForm({
|
||||
reauth: is_user_settings,
|
||||
});
|
||||
|
||||
console.log("upload_image_res", upload_image_res);
|
||||
|
||||
if (!upload_image_res.success) {
|
||||
throw new Error(
|
||||
upload_image_res.msg || "Couldn't upload Image",
|
||||
@@ -96,44 +99,7 @@ export default async function submitUserForm({
|
||||
}
|
||||
|
||||
if (create_or_update_user_res.success && target_user_id) {
|
||||
const delete_user_types = await adminCrudHandler({
|
||||
action: "delete",
|
||||
table: "user_types",
|
||||
sql_query: {
|
||||
query: {
|
||||
user_id: {
|
||||
value: target_user_id,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const user_types = form.user_types;
|
||||
|
||||
if (user_types?.[0]) {
|
||||
const add_user_types =
|
||||
await adminCrudHandler<BUN_SQLITE_WGUI_USER_TYPES>({
|
||||
action: "insert",
|
||||
table: "user_types",
|
||||
insert_data: user_types.map((ut) => ({
|
||||
user_id: target_user_id,
|
||||
user_type: ut,
|
||||
})),
|
||||
});
|
||||
|
||||
if (add_user_types.success) {
|
||||
if (existing_full?.id) {
|
||||
window.location.reload();
|
||||
} else {
|
||||
window.location.pathname = `/admin/people/${target_user_id}`;
|
||||
}
|
||||
} else {
|
||||
console.log("add_user_types", add_user_types);
|
||||
throw new Error(
|
||||
add_user_types.msg || "Couldn't add user types",
|
||||
);
|
||||
}
|
||||
}
|
||||
window.location.reload();
|
||||
} else {
|
||||
console.log("res", create_or_update_user_res);
|
||||
console.log("form", form);
|
||||
|
||||
Reference in New Issue
Block a user