Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add email in invite link (#20001)
ecmadaoa4b7514c87c4
diff --git a/backend/api/v1/workspace_service.go b/backend/api/v1/workspace_service.goindex 80cead88e0..9f6f46c448 100644--- a/backend/api/v1/workspace_service.go+++ b/backend/api/v1/workspace_service.go@@ -4,6 +4,7 @@ import ("context""fmt""log/slog"+ "net/url""strings""connectrpc.com/connect"@@ -386,10 +387,10 @@ func (s *WorkspaceService) sendInviteEmails(ctx context.Context, workspaceID strreturn}- workspaceLink := fmt.Sprintf("%s?workspace=%s", externalURL, workspaceID)for email, roleName := range invites {+ loginLink := fmt.Sprintf("%s?workspace=%s&email=%s", externalURL, url.QueryEscape(workspaceID), url.QueryEscape(email))subject := fmt.Sprintf("[Bytebase] You've been invited to workspace %q", workspaceTitle)- body := fmt.Sprintf("Hi,\n\nYou've been added to the Bytebase workspace %q as %s.\n\nSign in to get started:\n%s\n\n— Bytebase", workspaceTitle, roleName, workspaceLink)+ body := fmt.Sprintf("Hi,\n\nYou've been added to the Bytebase workspace %q as %s.\n\nSign in to get started:\n%s\n\n— Bytebase", workspaceTitle, roleName, loginLink)if err := sender.Send(ctx, &mailer.SendRequest{To: []string{email},Subject: subject,diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex bc0d94aa78..12b6a3f651 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -122,6 +122,7 @@"sign-in": {"demo-account": "Demo Account","forget-password": "Forgot your password?",+ "invited-email": "You've been invited. Please sign in with {email}","new-user": "New to Bytebase?","sign-in-with-idp": "Sign in with {idp}"},diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 37d0f9739f..2b0814a36d 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -122,6 +122,7 @@"sign-in": {"demo-account": "Demo Account","forget-password": "¿Olvidaste tu contraseña?",+ "invited-email": "Has sido invitado. Inicia sesión con {email}","new-user": "¿Nuevo en Bytebase?","sign-in-with-idp": "Iniciar sesión con {idp}"},diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 0446ffd0e8..8fd60663f4 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -122,6 +122,7 @@"sign-in": {"demo-account": "Demo Account","forget-password": "パスワードを忘れましたか?",+ "invited-email": "招待されました。{email} でログインしてください","new-user": "Bytebase を初めて使用しますか?","sign-in-with-idp": "{idp} 経由でログイン"},diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex c2bc1a3a2c..1ab67466c1 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -122,6 +122,7 @@"sign-in": {"demo-account": "Demo Account","forget-password": "Quên mật khẩu?",+ "invited-email": "Bạn đã được mời. Vui lòng đăng nhập bằng {email}","new-user": "Mới sử dụng Bytebase?","sign-in-with-idp": "Đăng nhập bằng {idp}"},diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f98c97645e..ea895e1c44 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -122,6 +122,7 @@"sign-in": {"demo-account": "Demo Account","forget-password": "忘记密码?",+ "invited-email": "您已被邀请,请使用 {email} 登录","new-user": "第一次使用 Bytebase?","sign-in-with-idp": "通过 {idp} 登录"},diff --git a/frontend/src/react/components/UserSelect.tsx b/frontend/src/react/components/UserSelect.tsxnew file mode 100644index 0000000000..48848e01a8--- /dev/null+++ b/frontend/src/react/components/UserSelect.tsx@@ -0,0 +1,121 @@+import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { Combobox, type ComboboxOption } from "@/react/components/ui/combobox";+import { useUserStore } from "@/store";+import { userNamePrefix } from "@/store/modules/v1/common";+import { ALL_USERS_USER_EMAIL } from "@/types";+import type { User } from "@/types/proto-es/v1/user_service_pb";+import { getDefaultPagination, isValidEmail } from "@/utils";++interface UserSelectProps {+ /** Selected user's full name, e.g. "users/[email protected]" (or empty). */+ value: string;+ onChange: (value: string) => void;+ disabled?: boolean;+ placeholder?: string;+ className?: string;+ /** Include the `users/allUsers` synthetic account in the list. */+ includeAllUsers?: boolean;+}++function toOption(user: User): ComboboxOption {+ const label = user.title || user.email;+ return {+ value: user.name,+ label,+ description: user.email && user.email !== label ? user.email : undefined,+ };+}++export function UserSelect({+ value,+ onChange,+ disabled,+ placeholder,+ className,+ includeAllUsers,+}: UserSelectProps) {+ const userStore = useUserStore();+ const [users, setUsers] = useState<User[]>([]);+ const [selectedUser, setSelectedUser] = useState<User | undefined>(undefined);+ const [search, setSearch] = useState("");+ // Track the latest in-flight request to ignore stale responses when the+ // user types quickly (a slow A can arrive after a fast B).+ const searchSeqRef = useRef(0);++ // Hydrate the selected user so its label renders even when it isn't in+ // the current search results.+ useEffect(() => {+ if (!value) {+ setSelectedUser(undefined);+ return;+ }+ let cancelled = false;+ userStore.getOrFetchUserByIdentifier({ identifier: value }).then((user) => {+ if (!cancelled) setSelectedUser(user);+ });+ return () => {+ cancelled = true;+ };+ }, [value, userStore]);++ const handleSearch = useCallback(+ (query: string) => {+ setSearch(query);+ const seq = ++searchSeqRef.current;+ userStore+ .fetchUserList({+ pageSize: getDefaultPagination(),+ filter: { query: query.trim() },+ })+ .then(({ users: fetched }) => {+ if (seq === searchSeqRef.current) setUsers(fetched);+ });+ },+ [userStore]+ );++ const options: ComboboxOption[] = useMemo(() => {+ const list: ComboboxOption[] = [];+ const seen = new Set<string>();+ if (includeAllUsers) {+ list.push({+ value: `${userNamePrefix}${ALL_USERS_USER_EMAIL}`,+ label: ALL_USERS_USER_EMAIL,+ });+ seen.add(`${userNamePrefix}${ALL_USERS_USER_EMAIL}`);+ }+ if (selectedUser && !seen.has(selectedUser.name)) {+ list.push(toOption(selectedUser));+ seen.add(selectedUser.name);+ }+ for (const user of users) {+ if (seen.has(user.name)) continue;+ list.push(toOption(user));+ seen.add(user.name);+ }+ // Allow selecting arbitrary emails typed in the search box — same pattern+ // as AccountMultiSelect. Supports SaaS flows where admins grant access to+ // emails before signup (invited-but-not-yet-signed-in accounts).+ const trimmed = search.trim();+ if (isValidEmail(trimmed) && !users.some((u) => u.email === trimmed)) {+ const customName = `${userNamePrefix}${trimmed}`;+ if (!seen.has(customName)) {+ list.push({ value: customName, label: trimmed });+ }+ }+ return list;+ }, [users, selectedUser, includeAllUsers, search]);++ return (+ <Combobox+ value={value}+ onChange={onChange}+ options={options}+ onSearch={handleSearch}+ placeholder={placeholder}+ disabled={disabled}+ className={className}+ portal+ />+ );+}diff --git a/frontend/src/react/components/ui/combobox.tsx b/frontend/src/react/components/ui/combobox.tsxindex cc25de0d62..96009fd133 100644--- a/frontend/src/react/components/ui/combobox.tsx+++ b/frontend/src/react/components/ui/combobox.tsx@@ -9,6 +9,7 @@ import {} from "react";import { createPortal } from "react-dom";import { cn } from "@/react/lib/utils";+import { HighlightLabelText } from "../HighlightLabelText";import { SearchInput } from "./search-input";export interface ComboboxOption {@@ -304,18 +305,20 @@ export function Combobox(props: ComboboxProps) {option.render()) : (<>- <span+ <HighlightLabelText+ text={option.label}+ keyword={search}className={cn("truncate",!multiple && isSelected && "text-accent font-medium")}- >- {option.label}- </span>+ />{option.description && (- <span className="text-xs text-control-light truncate">- {option.description}- </span>+ <HighlightLabelText+ text={option.description}+ keyword={search}+ className="text-xs text-control-light truncate"+ />)}</>)}diff --git a/frontend/src/react/pages/settings/GroupsPage.tsx b/frontend/src/react/pages/settings/GroupsPage.tsxindex 793c033fa5..86a82c9c11 100644--- a/frontend/src/react/pages/settings/GroupsPage.tsx+++ b/frontend/src/react/pages/settings/GroupsPage.tsx@@ -12,11 +12,19 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";import { useTranslation } from "react-i18next";import { ComponentPermissionGuard } from "@/react/components/ComponentPermissionGuard";import { FeatureBadge } from "@/react/components/FeatureBadge";+import { UserSelect } from "@/react/components/UserSelect";import { Alert, AlertDescription } from "@/react/components/ui/alert";import { Badge } from "@/react/components/ui/badge";import { Button } from "@/react/components/ui/button";import { Input } from "@/react/components/ui/input";import { SearchInput } from "@/react/components/ui/search-input";+import {+ Select,+ SelectContent,+ SelectItem,+ SelectTrigger,+ SelectValue,+} from "@/react/components/ui/select";import {Sheet,SheetBody,@@ -810,34 +818,39 @@ function GroupForm({<div className="flex flex-col gap-y-2">{members.map((member, index) => (<div key={index} className="flex items-center gap-x-2">- <Input+ <UserSelectclassName="flex-1"value={member.member}- onChange={(e) =>- handleMemberChange(index, "member", e.target.value)- }- placeholder="users/[email protected]"+ onChange={(val) => handleMemberChange(index, "member", val)}disabled={!allowEdit}/>- <select+ <Selectvalue={member.role}- onChange={(e) =>- handleMemberChange(- index,- "role",- Number(e.target.value) as GroupMember_Role- )- }- className="h-9 rounded-xs border border-control-border bg-transparent px-2 py-1 text-sm"+ onValueChange={(val: GroupMember_Role | null) => {+ if (val !== null) {+ handleMemberChange(index, "role", val);+ }+ }}disabled={!allowEdit}>- <option value={GroupMember_Role.OWNER}>- {t("settings.members.groups.form.role.owner")}- </option>- <option value={GroupMember_Role.MEMBER}>- {t("settings.members.groups.form.role.member")}- </option>- </select>+ <SelectTrigger className="h-9 w-36 shrink-0">+ <SelectValue>+ {(value: GroupMember_Role | null) =>+ value === GroupMember_Role.OWNER+ ? t("settings.members.groups.form.role.owner")+ : t("settings.members.groups.form.role.member")+ }+ </SelectValue>+ </SelectTrigger>+ <SelectContent>+ <SelectItem value={GroupMember_Role.OWNER}>+ {t("settings.members.groups.form.role.owner")}+ </SelectItem>+ <SelectItem value={GroupMember_Role.MEMBER}>+ {t("settings.members.groups.form.role.member")}+ </SelectItem>+ </SelectContent>+ </Select><Buttonvariant="ghost"size="icon"diff --git a/frontend/src/react/pages/settings/IDPsPage.tsx b/frontend/src/react/pages/settings/IDPsPage.tsxindex 804739cfab..6b9f5ea6a3 100644--- a/frontend/src/react/pages/settings/IDPsPage.tsx+++ b/frontend/src/react/pages/settings/IDPsPage.tsx@@ -1171,7 +1171,7 @@ function getTemplateList(hasEnterpriseSSOFeature: boolean): OAuth2Template[] {authUrl: "https://github.com/login/oauth/authorize",tokenUrl: "https://github.com/login/oauth/access_token",userInfoUrl: "https://api.github.com/user",- scopes: ["user", "user:email"],+ scopes: ["user:email"],skipTlsVerify: false,authStyle: OAuth2AuthStyle.IN_PARAMS,fieldMapping: create(FieldMappingSchema, {diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex eb7b4f0418..6654e8411f 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -25,6 +25,24 @@ import authRoutes, {AUTH_SIGNIN_MODULE,OAUTH2_CONSENT_MODULE,} from "./auth";++// Query params that are only meaningful on the signin page (pre-login).+// They're forwarded from the original URL to signin and stripped from the post-login redirect.+const SIGNIN_QUERY_PARAMS = [+ "idp",+ "workspace",+ "email",+ "token",+ "invitation",+] as const;++const stripSigninQueryParams = (fullPath: string): string => {+ const url = new URL(fullPath, window.location.origin);+ for (const param of SIGNIN_QUERY_PARAMS) {+ url.searchParams.delete(param);+ }+ return url.pathname + url.search + url.hash;+};import dashboardRoutes from "./dashboard";import {DATABASE_ROUTE_DASHBOARD,@@ -164,28 +182,17 @@ router.beforeEach((to, from, next) => {if (!authStore.isLoggedIn) {const query: LocationQueryRaw = {};- // Preserve important query parameters- if (to.query) {- // Preserve IDP parameter for OAuth flows- if (to.query["idp"]) {- query["idp"] = to.query["idp"];- }- // Preserve workspace parameter for workspace-scoped signin- if (to.query["workspace"]) {- query["workspace"] = to.query["workspace"];- }- // Preserve other auth-related parameters- if (to.query["token"]) {- query["token"] = to.query["token"];- }- if (to.query["invitation"]) {- query["invitation"] = to.query["invitation"];+ // Forward signin-only query params (consumed by the signin page itself).+ for (const param of SIGNIN_QUERY_PARAMS) {+ if (to.query[param]) {+ query[param] = to.query[param];}}- // Set redirect URL if not root path and not already set+ // Set redirect URL if not root path and not already set.+ // Strip signin-only params from the redirect — they're meaningless after login.if (to.fullPath !== "/" && !to.query["redirect"]) {- query["redirect"] = to.fullPath;+ query["redirect"] = stripSigninQueryParams(to.fullPath);}next({diff --git a/frontend/src/views/auth/Signin.vue b/frontend/src/views/auth/Signin.vueindex b97c46c657..4de3dd4292 100644--- a/frontend/src/views/auth/Signin.vue+++ b/frontend/src/views/auth/Signin.vue@@ -3,6 +3,13 @@<div class="mx-auto w-full max-w-sm"><BytebaseLogo class="mx-auto mb-8" />+ <BBAttention+ v-if="invitedEmail"+ class="mb-4"+ type="info"+ :title="$t('auth.sign-in.invited-email', { email: invitedEmail })"+ />+<div v-if="showSignInForm"><NCard><NTabs@@ -181,7 +188,7 @@ import { NButton, NCard, NTabPane, NTabs } from "naive-ui";import { storeToRefs } from "pinia";import { computed, onMounted, reactive, ref, watchEffect } from "vue";import { useRoute, useRouter } from "vue-router";-import { BBSpin, BBTextField } from "@/bbkit";+import { BBAttention, BBSpin, BBTextField } from "@/bbkit";import BytebaseLogo from "@/components/BytebaseLogo.vue";import DemoSigninForm from "@/components/DemoSigninForm.vue";import PasswordSigninForm from "@/components/PasswordSigninForm.vue";@@ -229,7 +236,7 @@ const authStore = useAuthStore();const identityProviderStore = useIdentityProviderStore();const state = reactive<LocalState>({- email: "",+ email: (route.query.email as string) || "",password: "",showPassword: false,isLoading: false,@@ -238,6 +245,10 @@ const initialized = ref(false);const { isDemo } = storeToRefs(actuatorStore);const { serverInfo, isSaaSMode } = storeToRefs(actuatorStore);+const invitedEmail = computed(+ () => (route.query.email as string | undefined) || ""+);+const disallowSignup = computed(() => !props.allowSignup || serverInfo.value?.restriction?.disallowSignup);