Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

feat: support profile setup (#20287)

ecmadao140e86268181
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f6beabf66f..20fc08cb5b 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -117,6 +117,7 @@
"invalid-or-expired-code": "Invalid or expired code. Please request a new one.",
"title": "Reset your password"
},
+ "profile-setup": "Profile Setup",
"sign-in": {
"code-sent-hint": "A verification code was sent to {email}.",
"demo-account": "Demo Account",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index b361a8184b..397af65dae 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -117,6 +117,7 @@
"invalid-or-expired-code": "Código inválido o caducado. Por favor solicita uno nuevo.",
"title": "Restablecer su contraseña"
},
+ "profile-setup": "Configurar perfil",
"sign-in": {
"code-sent-hint": "Se ha enviado un código de verificación a {email}.",
"demo-account": "Demo Account",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 372033c12f..432c9af488 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -117,6 +117,7 @@
"invalid-or-expired-code": "コードが無効または期限切れです。新しいコードをリクエストしてください。",
"title": "あなたのパスワードをリセット"
},
+ "profile-setup": "プロフィール設定",
"sign-in": {
"code-sent-hint": "{email} に認証コードを送信しました。",
"demo-account": "Demo Account",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 8e3df9428f..f089c6e1c7 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -117,6 +117,7 @@
"invalid-or-expired-code": "Mã không hợp lệ hoặc đã hết hạn. Vui lòng yêu cầu mã mới.",
"title": "Đặt lại mật khẩu của bạn"
},
+ "profile-setup": "Thiết lập hồ sơ",
"sign-in": {
"code-sent-hint": "Mã xác minh đã được gửi đến {email}.",
"demo-account": "Demo Account",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index dfe43d52f1..4ec0e2a8ba 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -117,6 +117,7 @@
"invalid-or-expired-code": "验证码无效或已过期,请重新申请。",
"title": "重置您的密码"
},
+ "profile-setup": "设置个人资料",
"sign-in": {
"code-sent-hint": "验证码已发送至 {email}。",
"demo-account": "Demo Account",
diff --git a/frontend/src/react/components/UserAvatar.tsx b/frontend/src/react/components/UserAvatar.tsx
index cb28f14ba5..7b78a367c2 100644
--- a/frontend/src/react/components/UserAvatar.tsx
+++ b/frontend/src/react/components/UserAvatar.tsx
@@ -27,10 +27,13 @@ export function getInitials(name: string) {
export function UserAvatar({
title,
+ colorSeed,
size = "md",
className,
}: {
title: string;
+ /** Stable string for color derivation (e.g. email). Defaults to title. */
+ colorSeed?: string;
size?: "sm" | "md";
className?: string;
}) {
@@ -42,7 +45,7 @@ export function UserAvatar({
dim,
className
)}
- style={{ backgroundColor: getAvatarColor(title) }}
+ style={{ backgroundColor: getAvatarColor(colorSeed ?? title) }}
>
{getInitials(title)}
</div>
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 1fe40f4530..d4d9602d7f 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -2388,6 +2388,8 @@
"workload-identity-tag-hint": "Leave empty to allow all tags"
},
"profile": {
+ "display-name": "Your name",
+ "display-name-placeholder": "Enter your name",
"email": "Email",
"password": "Password",
"password-confirm": "Password Confirm",
@@ -2397,7 +2399,13 @@
"phone": "Phone",
"phone-tips": "Be sure to include the country code +1xxxxxx",
"role": "Role",
- "subscription": "(Upgrade to enable role management)"
+ "setup-failed": "Failed to update profile.",
+ "setup-skip": "I'll do this later",
+ "setup-success": "Profile updated.",
+ "setup-title": "Welcome! Set up your profile",
+ "subscription": "(Upgrade to enable role management)",
+ "workspace-name": "Workspace name",
+ "workspace-name-placeholder": "Enter workspace name"
},
"sensitive-data": {
"algorithms": {
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index 7046003623..444d6fbe06 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -2376,6 +2376,8 @@
"workload-identity-tag-hint": "Leave empty to allow all tags"
},
"profile": {
+ "display-name": "Su nombre",
+ "display-name-placeholder": "Ingrese su nombre",
"email": "Correo electrónico",
"password": "Contraseña",
"password-confirm": "Confirmar contraseña",
@@ -2385,7 +2387,13 @@
"phone": "Número de móvil",
"phone-tips": "Asegúrese de incluir el código del país +1xxxxxx",
"role": "Rol",
- "subscription": "(Actualice para habilitar la gestión de roles)"
+ "setup-failed": "Error al actualizar el perfil.",
+ "setup-skip": "Lo haré después",
+ "setup-success": "Perfil actualizado.",
+ "setup-title": "¡Bienvenido! Configure su perfil",
+ "subscription": "(Actualice para habilitar la gestión de roles)",
+ "workspace-name": "Nombre del espacio de trabajo",
+ "workspace-name-placeholder": "Ingrese el nombre del espacio de trabajo"
},
"sensitive-data": {
"algorithms": {
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index 121dc1ee66..a4e0e3142d 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -2376,6 +2376,8 @@
"workload-identity-tag-hint": "Leave empty to allow all tags"
},
"profile": {
+ "display-name": "あなたの名前",
+ "display-name-placeholder": "名前を入力してください",
"email": "メールアドレス",
"password": "パスワード",
"password-confirm": "パスワードの確認",
@@ -2385,7 +2387,13 @@
"phone": "電話番号",
"phone-tips": "国コードを必ず含めてください +81xxxxxx",
"role": "ロール",
- "subscription": "(有料プランにアップグレードするとキャラクター管理が可能になります)"
+ "setup-failed": "プロフィールの更新に失敗しました。",
+ "setup-skip": "後で設定する",
+ "setup-success": "プロフィールが更新されました。",
+ "setup-title": "ようこそ!プロフィールを設定してください",
+ "subscription": "(有料プランにアップグレードするとキャラクター管理が可能になります)",
+ "workspace-name": "ワークスペース名",
+ "workspace-name-placeholder": "ワークスペース名を入力"
},
"sensitive-data": {
"algorithms": {
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index 08554c8d03..ce3560b38d 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -2376,6 +2376,8 @@
"workload-identity-tag-hint": "Leave empty to allow all tags"
},
"profile": {
+ "display-name": "Tên của bạn",
+ "display-name-placeholder": "Nhập tên của bạn",
"email": "Email",
"password": "Mật khẩu",
"password-confirm": "Xác nhận mật khẩu",
@@ -2385,7 +2387,13 @@
"phone": "Điện thoại",
"phone-tips": "Nhớ bao gồm mã quốc gia +1xxxxxx",
"role": "Vai trò",
- "subscription": "(Nâng cấp để kích hoạt quản lý vai trò)"
+ "setup-failed": "Cập nhật hồ sơ thất bại.",
+ "setup-skip": "Để sau",
+ "setup-success": "Hồ sơ đã được cập nhật.",
+ "setup-title": "Chào mừng! Thiết lập hồ sơ của bạn",
+ "subscription": "(Nâng cấp để kích hoạt quản lý vai trò)",
+ "workspace-name": "Tên không gian làm việc",
+ "workspace-name-placeholder": "Nhập tên không gian làm việc"
},
"sensitive-data": {
"algorithms": {
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index be86509f39..511c8fbc5d 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -2376,6 +2376,8 @@
"workload-identity-tag-hint": "留空则允许所有标签"
},
"profile": {
+ "display-name": "您的姓名",
+ "display-name-placeholder": "输入您的姓名",
"email": "邮箱",
"password": "密码",
"password-confirm": "确认密码",
@@ -2385,7 +2387,13 @@
"phone": "手机号",
"phone-tips": "请包含国家代码前缀 +86xxxxxx",
"role": "角色",
- "subscription": "(升级到付费方案来解锁角色管理)"
+ "setup-failed": "更新个人资料失败。",
+ "setup-skip": "稍后再说",
+ "setup-success": "个人资料已更新。",
+ "setup-title": "欢迎!设置您的个人资料",
+ "subscription": "(升级到付费方案来解锁角色管理)",
+ "workspace-name": "工作空间名称",
+ "workspace-name-placeholder": "输入工作空间名称"
},
"sensitive-data": {
"algorithms": {
diff --git a/frontend/src/react/pages/auth/ProfileSetupPage.tsx b/frontend/src/react/pages/auth/ProfileSetupPage.tsx
new file mode 100644
index 0000000000..8305367ec6
--- /dev/null
+++ b/frontend/src/react/pages/auth/ProfileSetupPage.tsx
@@ -0,0 +1,151 @@
+import { create } from "@bufbuild/protobuf";
+import { FieldMaskSchema } from "@bufbuild/protobuf/wkt";
+import { useState } from "react";
+import { useTranslation } from "react-i18next";
+import { UserAvatar } from "@/react/components/UserAvatar";
+import { Button } from "@/react/components/ui/button";
+import { Input } from "@/react/components/ui/input";
+import { useVueState } from "@/react/hooks/useVueState";
+import { router } from "@/router";
+import {
+ pushNotification,
+ useCurrentUserV1,
+ useUserStore,
+ useWorkspaceV1Store,
+} from "@/store";
+import { UpdateUserRequestSchema } from "@/types/proto-es/v1/user_service_pb";
+import { WorkspaceSchema } from "@/types/proto-es/v1/workspace_service_pb";
+import { hasWorkspacePermissionV2 } from "@/utils";
+
+export function ProfileSetupPage() {
+ const { t } = useTranslation();
+ const currentUser = useVueState(() => useCurrentUserV1().value);
+ const userStore = useUserStore();
+ const workspaceStore = useWorkspaceV1Store();
+ const workspace = useVueState(() => workspaceStore.currentWorkspace);
+ const workspacePolicy = useVueState(() => workspaceStore.workspaceIamPolicy);
+
+ // Show workspace name field only if the user is the sole member of the
+ // workspace (i.e. they just created it), not when they were invited.
+ const canRenameWorkspace =
+ hasWorkspacePermissionV2("bb.workspaces.update") &&
+ workspacePolicy.bindings.reduce(
+ (count, b) => count + b.members.length,
+ 0
+ ) === 1;
+
+ const [name, setName] = useState(currentUser?.title ?? "");
+ const [workspaceTitle, setWorkspaceTitle] = useState(workspace?.title ?? "");
+ const [saving, setSaving] = useState(false);
+
+ const redirectUrl = () => {
+ const q = new URLSearchParams(window.location.search);
+ return q.get("redirect") || "/";
+ };
+
+ const handleSave = async () => {
+ if (!currentUser?.name || !name.trim()) return;
+ setSaving(true);
+ try {
+ await userStore.updateUser(
+ create(UpdateUserRequestSchema, {
+ user: { name: currentUser.name, title: name.trim() },
+ updateMask: create(FieldMaskSchema, { paths: ["title"] }),
+ })
+ );
+ if (canRenameWorkspace && workspaceTitle.trim() && workspace?.name) {
+ await workspaceStore.updateWorkspace(
+ create(WorkspaceSchema, {
+ name: workspace.name,
+ title: workspaceTitle.trim(),
+ }),
+ ["title"]
+ );
+ }
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("settings.profile.setup-success"),
+ });
+ router.replace(redirectUrl());
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("settings.profile.setup-failed"),
+ });
+ } finally {
+ setSaving(false);
+ }
+ };
+
+ const handleSkip = () => {
+ router.replace(redirectUrl());
+ };
+
+ const displayName = name.trim() || currentUser?.email || "?";
+
+ return (
+ <div className="flex flex-col items-center justify-center min-h-screen px-4">
+ <div className="w-full max-w-sm flex flex-col items-center gap-y-6">
+ <UserAvatar
+ title={displayName}
+ colorSeed={currentUser?.email}
+ size="md"
+ className="!size-16 !text-2xl"
+ />
+
+ <div className="text-center">
+ <h1 className="text-xl font-semibold">
+ {t("settings.profile.setup-title")}
+ </h1>
+ </div>
+
+ <div className="w-full flex flex-col gap-y-4">
+ <div className="flex flex-col gap-y-1.5">
+ <label className="text-sm font-medium">
+ {t("settings.profile.display-name")}
+ </label>
+ <Input
+ value={name}
+ onChange={(e) => setName(e.target.value)}
+ placeholder={t("settings.profile.display-name-placeholder")}
+ autoFocus
+ onKeyDown={(e) => {
+ if (e.key === "Enter" && name.trim()) {
+ void handleSave();
+ }
+ }}
+ />
+ </div>
+
+ {canRenameWorkspace && (
+ <div className="flex flex-col gap-y-1.5">
+ <label className="text-sm font-medium">
+ {t("settings.profile.workspace-name")}
+ </label>
+ <Input
+ value={workspaceTitle}
+ onChange={(e) => setWorkspaceTitle(e.target.value)}
+ placeholder={t("settings.profile.workspace-name-placeholder")}
+ />
+ </div>
+ )}
+
+ <div className="flex flex-col gap-y-2 mt-2">
+ <Button
+ onClick={() => void handleSave()}
+ disabled={!name.trim() || saving}
+ className="w-full"
+ >
+ {t("common.save")}
+ </Button>
+ <Button variant="ghost" onClick={handleSkip} className="w-full">
+ {t("settings.profile.setup-skip")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/router/auth.ts b/frontend/src/router/auth.ts
index b1a7355c32..21a685d2e9 100644
--- a/frontend/src/router/auth.ts
+++ b/frontend/src/router/auth.ts
@@ -10,6 +10,7 @@ export const AUTH_PASSWORD_RESET_MODULE = "auth.password.reset";
export const AUTH_PASSWORD_FORGOT_MODULE = "auth.password.forgot";
export const AUTH_OAUTH_CALLBACK_MODULE = "auth.oauth.callback";
export const AUTH_OIDC_CALLBACK_MODULE = "auth.oidc.callback";
+export const AUTH_PROFILE_SETUP_MODULE = "auth.profile.setup";
export const AUTH_2FA_SETUP_MODULE = "auth.2fa.setup";
export const OAUTH2_CONSENT_MODULE = "oauth2.consent";
@@ -80,6 +81,13 @@ const authRoutes: RouteRecordRaw[] = [
component: reactPage,
props: { page: "MultiFactorPage" },
},
+ {
+ path: "profile-setup",
+ name: AUTH_PROFILE_SETUP_MODULE,
+ meta: { title: () => t("auth.profile-setup") },
+ component: reactPage,
+ props: { page: "ProfileSetupPage" },
+ },
],
},
{
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 32c15edffc..0423dc46ab 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -22,6 +22,7 @@ import authRoutes, {
AUTH_OAUTH_CALLBACK_MODULE,
AUTH_OIDC_CALLBACK_MODULE,
AUTH_PASSWORD_RESET_MODULE,
+ AUTH_PROFILE_SETUP_MODULE,
AUTH_SIGNIN_MODULE,
OAUTH2_CONSENT_MODULE,
} from "./auth";
@@ -122,7 +123,8 @@ router.beforeEach((to, from, next) => {
if (
authStore.isLoggedIn &&
(to.name === AUTH_2FA_SETUP_MODULE ||
- to.name === AUTH_PASSWORD_RESET_MODULE)
+ to.name === AUTH_PASSWORD_RESET_MODULE ||
+ to.name === AUTH_PROFILE_SETUP_MODULE)
) {
next();
return;
diff --git a/frontend/src/store/modules/v1/auth.ts b/frontend/src/store/modules/v1/auth.ts
index f2a864fdc7..bdff29c54f 100644
--- a/frontend/src/store/modules/v1/auth.ts
+++ b/frontend/src/store/modules/v1/auth.ts
@@ -10,6 +10,7 @@ import { router } from "@/router";
import {
AUTH_MFA_MODULE,
AUTH_PASSWORD_RESET_MODULE,
+ AUTH_PROFILE_SETUP_MODULE,
AUTH_SIGNIN_MODULE,
} from "@/router/auth";
import { SETUP_MODULE } from "@/router/setup";
@@ -146,6 +147,14 @@ export const useAuthStore = defineStore("auth_v1", () => {
},
});
}
+ if (actuatorStore.isSaaSMode && resp.user && needsProfileSetup(resp.user)) {
+ return router.push({
+ name: AUTH_PROFILE_SETUP_MODULE,
+ query: {
+ redirect: nextPage,
+ },
+ });
+ }
if (redirect) {
router.replace(nextPage);
}
@@ -252,3 +261,20 @@ export const useCurrentUserV1 = () => {
unknownUser()
);
};
+
+/**
+ * Returns true if the user should be prompted to set up their profile.
+ * First-time login with an auto-generated name (email local-part or full email).
+ */
+function needsProfileSetup(user: User): boolean {
+ // Only prompt on first login (lastLoginTime is not set yet).
+ if (user.profile?.lastLoginTime) return false;
+ const name = user.title;
+ const email = user.email;
+ if (!name || !email) return false;
+ // Name matches full email or email local-part → auto-generated.
+ if (name === email) return true;
+ const atIndex = email.indexOf("@");
+ if (atIndex > 0 && name === email.substring(0, atIndex)) return true;
+ return false;
+}