Skip to content

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

chore: change user page link (#9214)

ecmadao3d8897351da9
diff --git a/backend/api/v1/auth_service.go b/backend/api/v1/auth_service.go
index ea8014c0c4..8fc8df0498 100644
--- a/backend/api/v1/auth_service.go
+++ b/backend/api/v1/auth_service.go
@@ -72,11 +72,18 @@ func NewAuthService(store *store.Store, secret string, tokenDuration time.Durati
// GetUser gets a user.
func (s *AuthService) GetUser(ctx context.Context, request *v1pb.GetUserRequest) (*v1pb.User, error) {
+ find := &store.FindUserMessage{}
userID, err := common.GetUserID(request.Name)
if err != nil {
- return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ email, err := common.GetUserEmail(request.Name)
+ if err != nil {
+ return nil, status.Errorf(codes.InvalidArgument, err.Error())
+ }
+ find.Email = &email
+ } else {
+ find.ID = &userID
}
- user, err := s.store.GetUserByID(ctx, userID)
+ user, err := s.store.GetUser(ctx, find)
if err != nil {
return nil, status.Errorf(codes.Internal, "failed to get user, error: %v", err)
}
diff --git a/frontend/src/components/InboxList.vue b/frontend/src/components/InboxList.vue
index 63212265af..1308ebf297 100644
--- a/frontend/src/components/InboxList.vue
+++ b/frontend/src/components/InboxList.vue
@@ -20,7 +20,7 @@
>
<template v-if="showCreator(inbox.activity)">
<router-link
- :to="`/u/${getUserId(inbox.activity)}`"
+ :to="`/users/${getUserEmail(inbox.activity)}`"
class="mr-1 font-medium text-main hover:underline"
@click.stop
>{{ getUser(inbox.activity)?.title }}</router-link
@@ -73,7 +73,7 @@ import {
LogEntity_Action,
LogEntity_Level,
} from "@/types/proto/v1/logging_service";
-import { extractUserResourceName, extractUserUID } from "@/utils";
+import { extractUserResourceName } from "@/utils";
import PrincipalAvatar from "../components/PrincipalAvatar.vue";
import {
ActivityIssueCommentCreatePayload,
@@ -98,14 +98,13 @@ const inboxV1Store = useInboxV1Store();
const activityV1Store = useActivityV1Store();
const router = useRouter();
-const getUser = (activity: LogEntity | undefined) => {
- const email = extractUserResourceName(activity?.creator ?? "");
- return useUserStore().getUserByEmail(email);
+const getUserEmail = (activity: LogEntity | undefined) => {
+ return extractUserResourceName(activity?.creator ?? "");
};
-const getUserId = (activity: LogEntity | undefined) => {
- const username = getUser(activity)?.name ?? "";
- return extractUserUID(username);
+const getUser = (activity: LogEntity | undefined) => {
+ const email = getUserEmail(activity);
+ return useUserStore().getUserByEmail(email);
};
const actionLink = (activity: LogEntity | undefined): string => {
diff --git a/frontend/src/components/Issue/activity/ActionCreator.vue b/frontend/src/components/Issue/activity/ActionCreator.vue
index e8a2ea53f4..c462fb56b1 100644
--- a/frontend/src/components/Issue/activity/ActionCreator.vue
+++ b/frontend/src/components/Issue/activity/ActionCreator.vue
@@ -1,7 +1,7 @@
<template>
<router-link
v-if="userEmail !== SYSTEM_BOT_EMAIL"
- :to="`/u/${userId}`"
+ :to="`/users/${userEmail}`"
class="font-medium text-main whitespace-nowrap hover:underline"
exact-active-class=""
>{{ user?.title }}</router-link
@@ -23,7 +23,7 @@ import { computed } from "vue";
import { useUserStore } from "@/store";
import { SYSTEM_BOT_EMAIL } from "@/types";
import { LogEntity } from "@/types/proto/v1/logging_service";
-import { extractUserResourceName, extractUserUID } from "@/utils";
+import { extractUserResourceName } from "@/utils";
const props = defineProps<{
activity: LogEntity;
@@ -36,9 +36,4 @@ const userEmail = computed(() => {
const user = computed(() => {
return useUserStore().getUserByEmail(userEmail.value);
});
-
-const userId = computed(() => {
- const username = user.value?.name ?? "";
- return extractUserUID(username);
-});
</script>
diff --git a/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionCreator.vue b/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionCreator.vue
index e8a2ea53f4..c462fb56b1 100644
--- a/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionCreator.vue
+++ b/frontend/src/components/IssueV1/components/ActivitySection/Activity/ActionCreator.vue
@@ -1,7 +1,7 @@
<template>
<router-link
v-if="userEmail !== SYSTEM_BOT_EMAIL"
- :to="`/u/${userId}`"
+ :to="`/users/${userEmail}`"
class="font-medium text-main whitespace-nowrap hover:underline"
exact-active-class=""
>{{ user?.title }}</router-link
@@ -23,7 +23,7 @@ import { computed } from "vue";
import { useUserStore } from "@/store";
import { SYSTEM_BOT_EMAIL } from "@/types";
import { LogEntity } from "@/types/proto/v1/logging_service";
-import { extractUserResourceName, extractUserUID } from "@/utils";
+import { extractUserResourceName } from "@/utils";
const props = defineProps<{
activity: LogEntity;
@@ -36,9 +36,4 @@ const userEmail = computed(() => {
const user = computed(() => {
return useUserStore().getUserByEmail(userEmail.value);
});
-
-const userId = computed(() => {
- const username = user.value?.name ?? "";
- return extractUserUID(username);
-});
</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Description.vue b/frontend/src/components/IssueV1/components/HeaderSection/Description.vue
index 2a738122c8..a96630f273 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Description.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Description.vue
@@ -14,7 +14,7 @@
>
<template #creator>
<router-link
- :to="`/u/${extractUserUID(creator.name)}`"
+ :to="`/users/${creator.email}`"
class="font-medium text-control hover:underline"
>{{ creator.title }}</router-link
>
@@ -30,7 +30,7 @@
import { computed } from "vue";
import HumanizeDate from "@/components/misc/HumanizeDate.vue";
import { useUserStore } from "@/store";
-import { extractUserResourceName, extractUserUID } from "@/utils";
+import { extractUserResourceName } from "@/utils";
import { useIssueContext } from "../../logic";
const { isCreating, issue } = useIssueContext();
diff --git a/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberTable.vue b/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberTable.vue
index e00a530c0d..678c0a01e0 100644
--- a/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberTable.vue
+++ b/frontend/src/components/ProjectMember/ProjectMemberTable/ProjectMemberTable.vue
@@ -36,7 +36,7 @@
<div class="flex flex-row items-center space-x-2">
<template v-if="projectMember.user.email !== ALL_USERS_USER_NAME">
<router-link
- :to="`/u/${extractUserUID(projectMember.user.name)}`"
+ :to="`/users/${projectMember.user.email}`"
class="normal-link"
>{{ projectMember.user.title }}</router-link
>
@@ -159,7 +159,6 @@ import {
hasWorkspacePermissionV1,
displayRoleTitle,
hasPermissionInProjectV1,
- extractUserUID,
} from "@/utils";
import {
getExpiredTimeString,
diff --git a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
index d9141fc2a2..66b9b55c41 100644
--- a/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
+++ b/frontend/src/components/SensitiveData/SensitiveColumnDrawer.vue
@@ -83,7 +83,7 @@
<UserAvatar size="SMALL" :user="item.user" />
<div class="flex flex-col">
<router-link
- :to="`/u/${extractUserUID(item.user.name)}`"
+ :to="`/users/${item.user.email}`"
class="normal-link"
>
{{ item.user.title }}
@@ -206,7 +206,7 @@ import {
MaskingExceptionPolicy_MaskingException,
MaskingExceptionPolicy_MaskingException_Action,
} from "@/types/proto/v1/org_policy_service";
-import { hasWorkspacePermissionV1, extractUserUID } from "@/utils";
+import { hasWorkspacePermissionV1 } from "@/utils";
import { SensitiveColumn } from "./types";
import { getMaskDataIdentifier, isCurrentColumnException } from "./utils";
diff --git a/frontend/src/components/User/Settings/UserTable.vue b/frontend/src/components/User/Settings/UserTable.vue
index 5a73912a44..5f1af0e110 100644
--- a/frontend/src/components/User/Settings/UserTable.vue
+++ b/frontend/src/components/User/Settings/UserTable.vue
@@ -54,10 +54,7 @@
<div class="flex flex-row">
<div class="flex flex-col">
<div class="flex flex-row items-center space-x-2">
- <router-link
- :to="`/u/${extractUserUID(user.name)}`"
- class="normal-link"
- >
+ <router-link :to="`/users/${user.email}`" class="normal-link">
{{ user.title }}
</router-link>
<span
@@ -187,7 +184,7 @@ import {
import { SYSTEM_BOT_USER_NAME } from "@/types";
import { User, UserRole, UserType } from "@/types/proto/v1/auth_service";
import { State } from "@/types/proto/v1/common";
-import { hasWorkspacePermissionV1, extractUserUID } from "@/utils";
+import { hasWorkspacePermissionV1 } from "@/utils";
import UserAvatar from "../UserAvatar.vue";
import { copyServiceKeyToClipboardIfNeeded } from "./common";
diff --git a/frontend/src/components/v2/Model/User/UserByEmail.vue b/frontend/src/components/v2/Model/User/UserByEmail.vue
index 0efc694087..654a7005cd 100644
--- a/frontend/src/components/v2/Model/User/UserByEmail.vue
+++ b/frontend/src/components/v2/Model/User/UserByEmail.vue
@@ -12,7 +12,6 @@
import { computed } from "vue";
import { useUserStore } from "@/store";
import { getUserEmailFromIdentifier } from "@/store/modules/v1/common";
-import { extractUserUID } from "@/utils";
const props = withDefaults(
defineProps<{
@@ -36,7 +35,7 @@ const user = computed(() => {
const bindings = computed(() => {
if (props.link) {
- const to = user.value ? `/u/${extractUserUID(user.value.name)}` : "/404";
+ const to = user.value ? `/users/${user.value.email}` : "/404";
return {
to,
activeClass: "",
diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.ts
index 7f6fd74478..452dab6129 100644
--- a/frontend/src/router/index.ts
+++ b/frontend/src/router/index.ts
@@ -330,14 +330,15 @@ const routes: Array<RouteRecordRaw> = [
// perspective, they are more familiar with the "user" concept.
// We make an exception to use a shorthand here because it's a commonly
// accessed endpoint, and maybe in the future, we will further provide a
- // shortlink such as u/<<uid>>
- path: "u/:principalId",
+ // shortlink such as users/<<email>>
+ path: "users/:principalEmail",
name: "workspace.profile",
meta: {
title: (route: RouteLocationNormalized) => {
- const userUID = route.params.principalId as string;
+ const principalEmail = route.params.principalEmail as string;
const user =
- useUserStore().getUserById(userUID) ?? unknownUser();
+ useUserStore().getUserByEmail(principalEmail) ??
+ unknownUser();
return user.title;
},
},
@@ -1186,7 +1187,7 @@ router.beforeEach((to, from, next) => {
}
const routerSlug = routerStore.routeSlug(to);
- const principalId = routerSlug.principalId;
+ const principalEmail = routerSlug.principalEmail;
const environmentSlug = routerSlug.environmentSlug;
const projectSlug = routerSlug.projectSlug;
const projectWebhookSlug = routerSlug.projectWebhookSlug;
@@ -1200,9 +1201,9 @@ router.beforeEach((to, from, next) => {
const ssoName = routerSlug.ssoName;
const sqlReviewPolicySlug = routerSlug.sqlReviewPolicySlug;
- if (principalId) {
+ if (principalEmail) {
useUserStore()
- .getOrFetchUserById(String(principalId))
+ .getOrFetchUserById(principalEmail)
.then(() => {
next();
})
diff --git a/frontend/src/store/modules/router.ts b/frontend/src/store/modules/router.ts
index fdbf0855e0..c5f7f35e76 100644
--- a/frontend/src/store/modules/router.ts
+++ b/frontend/src/store/modules/router.ts
@@ -18,14 +18,14 @@ export const useRouterStore = defineStore("router", {
},
routeSlug(currentRoute: RouteLocationNormalized): RouterSlug {
{
- // /u/:principalId
+ // /users/:email
// Total 2 elements, 2nd element is the principal id
const profileComponents = currentRoute.path.match(
- "/u/([0-9a-zA-Z_-]+)"
+ /\/users\/(\S+@\S+\.\S+)/
) || ["/", undefined];
if (profileComponents[1]) {
return {
- principalId: parseInt(profileComponents[1]),
+ principalEmail: profileComponents[1],
};
}
}
diff --git a/frontend/src/types/common.ts b/frontend/src/types/common.ts
index cff80e6578..e55293e75f 100644
--- a/frontend/src/types/common.ts
+++ b/frontend/src/types/common.ts
@@ -3,7 +3,7 @@ import { EMPTY_ID, UNKNOWN_ID } from "./const";
import { DataSource } from "./dataSource";
import { Database } from "./database";
import { Environment } from "./environment";
-import { CommandId, CommandRegisterId, PrincipalId } from "./id";
+import { CommandId, CommandRegisterId } from "./id";
import { Instance } from "./instance";
import { Issue } from "./issue";
import { Pipeline, Stage, Task, TaskProgress } from "./pipeline";
@@ -39,7 +39,7 @@ export type RowStatus = "NORMAL" | "ARCHIVED";
// Router
export type RouterSlug = {
- principalId?: PrincipalId;
+ principalEmail?: string;
environmentSlug?: string;
projectSlug?: string;
projectWebhookSlug?: string;
diff --git a/frontend/src/types/proto/v1/auth_service.ts b/frontend/src/types/proto/v1/auth_service.ts
index cbc4cd064c..eaf1a01fc1 100644
--- a/frontend/src/types/proto/v1/auth_service.ts
+++ b/frontend/src/types/proto/v1/auth_service.ts
@@ -100,7 +100,7 @@ export function userRoleToJSON(object: UserRole): string {
export interface GetUserRequest {
/**
* The name of the user to retrieve.
- * Format: users/{user}
+ * Format: users/{user uid or user email}
*/
name: string;
}
diff --git a/proto/gen/grpc-doc/v1/README.md b/proto/gen/grpc-doc/v1/README.md
index 4e31bf878d..0328a40317 100644
--- a/proto/gen/grpc-doc/v1/README.md
+++ b/proto/gen/grpc-doc/v1/README.md
@@ -1704,7 +1704,7 @@ DATABASE_BACKUP_POLICY_VIOLATION is the anomaly type for database backup policy
| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
-| name | [string](#string) | | The name of the user to retrieve. Format: users/{user} |
+| name | [string](#string) | | The name of the user to retrieve. Format: users/{user uid or user email} |
diff --git a/proto/generated-go/v1/auth_service.pb.go b/proto/generated-go/v1/auth_service.pb.go
index b1f658382e..45aaee7704 100644
--- a/proto/generated-go/v1/auth_service.pb.go
+++ b/proto/generated-go/v1/auth_service.pb.go
@@ -133,7 +133,7 @@ type GetUserRequest struct {
unknownFields protoimpl.UnknownFields
// The name of the user to retrieve.
- // Format: users/{user}
+ // Format: users/{user uid or user email}
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
}
diff --git a/proto/v1/auth_service.proto b/proto/v1/auth_service.proto
index ea110bccba..ce3c67b44e 100644
--- a/proto/v1/auth_service.proto
+++ b/proto/v1/auth_service.proto
@@ -67,7 +67,7 @@ service AuthService {
message GetUserRequest {
// The name of the user to retrieve.
- // Format: users/{user}
+ // Format: users/{user uid or user email}
string name = 1 [(google.api.field_behavior) = REQUIRED];
}