From 05cd4694609b4f91c9e0ccab1eed7adba0cdc3f0 Mon Sep 17 00:00:00 2001
From: shatfield4
Date: Tue, 25 Feb 2025 17:45:58 -0800
Subject: [PATCH 1/6] add bio to users table
---
.../UserMenu/AccountModal/index.jsx | 21 ++++++++++++++++++-
server/endpoints/system.js | 6 +++++-
server/models/user.js | 1 +
.../20250226005538_init/migration.sql | 2 ++
server/prisma/schema.prisma | 1 +
5 files changed, 29 insertions(+), 2 deletions(-)
create mode 100644 server/prisma/migrations/20250226005538_init/migration.sql
diff --git a/frontend/src/components/UserMenu/AccountModal/index.jsx b/frontend/src/components/UserMenu/AccountModal/index.jsx
index 9de86893486..d4a6e4da2d7 100644
--- a/frontend/src/components/UserMenu/AccountModal/index.jsx
+++ b/frontend/src/components/UserMenu/AccountModal/index.jsx
@@ -52,11 +52,16 @@ export default function AccountModal({ user, hideModal }) {
let storedUser = JSON.parse(localStorage.getItem(AUTH_USER));
if (storedUser) {
- storedUser.username = data.username;
+ Object.keys(data).forEach(key => {
+ if (key !== 'password') {
+ storedUser[key] = data[key];
+ }
+ });
localStorage.setItem(AUTH_USER, JSON.stringify(storedUser));
}
showToast("Profile updated.", "success", { clear: true });
hideModal();
+ window.location.reload();
} else {
showToast(`Failed to update user: ${error}`, "error");
}
@@ -164,6 +169,20 @@ export default function AccountModal({ user, hideModal }) {
Password must be at least 8 characters long
+
+
+
+
diff --git a/server/endpoints/system.js b/server/endpoints/system.js
index 3b578f94a21..75b11223e26 100644
--- a/server/endpoints/system.js
+++ b/server/endpoints/system.js
@@ -1082,7 +1082,7 @@ function systemEndpoints(app) {
app.post("/system/user", [validatedRequest], async (request, response) => {
try {
const sessionUser = await userFromSession(request, response);
- const { username, password } = reqBody(request);
+ const { username, password, bio } = reqBody(request);
const id = Number(sessionUser.id);
if (!id) {
@@ -1098,6 +1098,10 @@ function systemEndpoints(app) {
updates.password = String(password);
}
+ if (bio) {
+ updates.bio = String(bio);
+ }
+
if (Object.keys(updates).length === 0) {
response
.status(400)
diff --git a/server/models/user.js b/server/models/user.js
index e6915d9dcd4..9bb25b79191 100644
--- a/server/models/user.js
+++ b/server/models/user.js
@@ -22,6 +22,7 @@ const User = {
"role",
"suspended",
"dailyMessageLimit",
+ "bio",
],
validations: {
username: (newValue = "") => {
diff --git a/server/prisma/migrations/20250226005538_init/migration.sql b/server/prisma/migrations/20250226005538_init/migration.sql
new file mode 100644
index 00000000000..4902fbc6859
--- /dev/null
+++ b/server/prisma/migrations/20250226005538_init/migration.sql
@@ -0,0 +1,2 @@
+-- AlterTable
+ALTER TABLE "users" ADD COLUMN "bio" TEXT DEFAULT '';
diff --git a/server/prisma/schema.prisma b/server/prisma/schema.prisma
index 37c82d4ddfc..8372d33a478 100644
--- a/server/prisma/schema.prisma
+++ b/server/prisma/schema.prisma
@@ -68,6 +68,7 @@ model users {
createdAt DateTime @default(now())
lastUpdatedAt DateTime @default(now())
dailyMessageLimit Int?
+ bio String? @default("")
workspace_chats workspace_chats[]
workspace_users workspace_users[]
embed_configs embed_configs[]
From 53f4fd424ad9b2ae73c6a6f7253e5762f4b166e1 Mon Sep 17 00:00:00 2001
From: shatfield4
Date: Tue, 25 Feb 2025 17:46:28 -0800
Subject: [PATCH 2/6] lint
---
frontend/src/components/UserMenu/AccountModal/index.jsx | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/frontend/src/components/UserMenu/AccountModal/index.jsx b/frontend/src/components/UserMenu/AccountModal/index.jsx
index d4a6e4da2d7..47c06665035 100644
--- a/frontend/src/components/UserMenu/AccountModal/index.jsx
+++ b/frontend/src/components/UserMenu/AccountModal/index.jsx
@@ -52,8 +52,8 @@ export default function AccountModal({ user, hideModal }) {
let storedUser = JSON.parse(localStorage.getItem(AUTH_USER));
if (storedUser) {
- Object.keys(data).forEach(key => {
- if (key !== 'password') {
+ Object.keys(data).forEach((key) => {
+ if (key !== "password") {
storedUser[key] = data[key];
}
});
From d3f4b2f091c4aaf4d9e400c3d5cbff8e84df4dcf Mon Sep 17 00:00:00 2001
From: shatfield4
Date: Tue, 25 Feb 2025 18:05:02 -0800
Subject: [PATCH 3/6] add bio field to edit user admin page
---
.../pages/Admin/Users/NewUserModal/index.jsx | 15 +++++++++
.../Users/UserRow/EditUserModal/index.jsx | 31 ++++++++++++++++++-
2 files changed, 45 insertions(+), 1 deletion(-)
diff --git a/frontend/src/pages/Admin/Users/NewUserModal/index.jsx b/frontend/src/pages/Admin/Users/NewUserModal/index.jsx
index 54dab87ee4d..8b11c1a1128 100644
--- a/frontend/src/pages/Admin/Users/NewUserModal/index.jsx
+++ b/frontend/src/pages/Admin/Users/NewUserModal/index.jsx
@@ -95,6 +95,21 @@ export default function NewUserModal({ closeModal }) {
Password must be at least 8 characters long
+
+
+
+
+
+
+
+