Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(desktop): add realname auth #4931

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion frontend/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,11 @@
"i18n-ally.displayLanguage": "zh",
"i18n-ally.namespace": true,
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key"
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key",
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
8 changes: 7 additions & 1 deletion frontend/desktop/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,11 @@
"i18n-ally.displayLanguage": "zh",
"i18n-ally.namespace": true,
"i18n-ally.pathMatcher": "{locale}/{namespaces}.json",
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key"
"i18n-ally.extract.targetPickingStrategy": "most-similar-by-key",
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
}
7 changes: 4 additions & 3 deletions frontend/desktop/data/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ cloud:
regionUID: "thisiaregionuid"
certSecretName: "wildcard-cert"
common:
guideEnabled: "false"
apiEnabled: "false"
rechargeEnabled: "false"
realNameAuthEnabled: false
guideEnabled: false
apiEnabled: false
rechargeEnabled: false
cfSiteKey: ""
database:
mongodbURI: "thisismongodburi"
Expand Down
3 changes: 3 additions & 0 deletions frontend/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@chakra-ui/system": "^2.6.1",
"@emotion/react": "^11.11.1",
"@emotion/styled": "^11.11.0",
"@hookform/resolvers": "^3.9.0",
"@kubernetes/client-node": "^0.18.1",
"@marsidev/react-turnstile": "^0.5.3",
"@prisma/client": "^5.10.2",
Expand Down Expand Up @@ -69,8 +70,10 @@
"sass": "^1.68.0",
"sealos-desktop-sdk": "workspace:*",
"sharp": "^0.32.6",
"tencentcloud-sdk-nodejs": "4.0.905",
"uuid": "^9.0.1",
"xml2js": "^0.6.2",
"zod": "^3.23.8",
"zustand": "^4.4.1"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
-- CreateTable
CREATE TABLE "UserRealNameInfo" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"userUid" UUID NOT NULL,
"realName" STRING,
"idCard" STRING,
"phone" STRING,
"isVerified" BOOL NOT NULL DEFAULT false,
"idVerifyFailedTimes" INT4 NOT NULL DEFAULT 0,
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(3) NOT NULL,
"additionalInfo" JSONB,

CONSTRAINT "UserRealNameInfo_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "RestrictedUser" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"userUid" UUID NOT NULL,
"restrictedLevel" INT4 NOT NULL,
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(3) NOT NULL,
"additionalInfo" JSONB,

CONSTRAINT "RestrictedUser_pkey" PRIMARY KEY ("id")
);

-- CreateTable
CREATE TABLE "RealNameAuthProvider" (
"id" UUID NOT NULL DEFAULT gen_random_uuid(),
"backend" STRING NOT NULL,
"authType" STRING NOT NULL,
"maxFailedTimes" INT4 NOT NULL,
"config" JSONB,
"createdAt" TIMESTAMPTZ(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
"updatedAt" TIMESTAMPTZ(3) NOT NULL,

CONSTRAINT "RealNameAuthProvider_pkey" PRIMARY KEY ("id")
);

-- CreateIndex
CREATE UNIQUE INDEX "UserRealNameInfo_userUid_key" ON "UserRealNameInfo"("userUid");

-- CreateIndex
CREATE UNIQUE INDEX "RestrictedUser_userUid_key" ON "RestrictedUser"("userUid");
38 changes: 38 additions & 0 deletions frontend/desktop/prisma/global/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,44 @@ model InviteReward {
inviteFrom String @db.Uuid
}

model UserRealNameInfo {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
userUid String @unique @db.Uuid
realName String?
idCard String?
phone String?
isVerified Boolean @default(false)
idVerifyFailedTimes Int @default(0)
createdAt DateTime @default(now()) @db.Timestamptz(3)
updatedAt DateTime @updatedAt @db.Timestamptz(3)
additionalInfo Json?

@@map("UserRealNameInfo")
}

model RestrictedUser {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
userUid String @unique @db.Uuid
restrictedLevel Int
createdAt DateTime @default(now()) @db.Timestamptz(3)
updatedAt DateTime @updatedAt @db.Timestamptz(3)
additionalInfo Json?

@@map("RestrictedUser")
}

model RealNameAuthProvider {
id String @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
backend String
authType String
maxFailedTimes Int
config Json?
createdAt DateTime @default(now()) @db.Timestamptz(3)
updatedAt DateTime @updatedAt @db.Timestamptz(3)

@@map("RealNameAuthProvider")
}

enum ProviderType {
PHONE
GITHUB
Expand Down
18 changes: 15 additions & 3 deletions frontend/desktop/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@
"healthy_pod": "Healthy Pod: {{count}}",
"hello_welcome": "Hello, welcome to",
"help_you_enable_high_availability_database": "Help you enable high availability database",
"idCard": "ID CARD",
"idCard_invalid": "INVAILD ID CARD FORMAT",
"in_payment": "In Payment ...",
"in_time": "In Time",
"insufficient_balance_tips": "There is currently an outstanding balance in your account. In order to successfully complete the account cancellation process, please settle the outstanding balance first.",
Expand Down Expand Up @@ -101,20 +103,23 @@
"member_list": "Member List",
"memory": "Memory",
"merge": "merge",
"merge_account_title": "Account has been bound",
"merge_account_tips1": "The account you are trying to bind has been used by another user. Due to conflicting binding methods, the accounts cannot be merged.",
"merge_account_tips2": "The account you are trying to bind has been used by another user. You can choose to merge accounts to manage your information and settings in a unified way. After the merge is completed, your private workspace may be converted into a regular workspace. Do you want to merge accounts now?",
"merge_account_title": "Account has been bound",
"message_center": "Message Center",
"monitor": "Monitor",
"more_apps": "More Apps",
"name": "Name",
"name_of_team": "Name of Workspace",
"name_required": "The name format is wrong",
"new_email": "New email",
"new_phone": "New mobile number",
"newpassword": "New Password",
"next": "Next",
"next_time": "Next",
"nickname": "Nickname",
"no_apps_found": "No Apps Found",
"no_realname_auth": "NO REALNAME AUTH",
"noworkspacecreated": "You haven't created a workspace yet",
"official_account_login": "Official account login",
"old_email": "Old email",
Expand All @@ -123,17 +128,21 @@
"order_number": "Order Number",
"password": "Password",
"password_login": "with Password",
"password_mis_match": "Passwords do not match",
"password_tips": "Password must be 8 characters or more",
"passwordchangesuccess": "Password changed successfully",
"password_mis_match": "Passwords do not match",
"pay_with_stripe": "Pay With Stripe",
"pay_with_wechat": "Pay With Wechat",
"payment_result": "Payment Result",
"payment_status": "Payment Status",
"payment_successful": "Payment Successful",
"phone": "Phone",
"phone_invalid": "Invalid phone number format",
"phone_number_tips": "Phone Number",
"phonechangesuccess": "Mobile phone number modified successfully",
"placeholders_idCard": "Please enter your ID card number",
"placeholders_name": "Please enter your name",
"placeholders_phone": "Please enter your phone number",
"please_read_and_agree_to_the_agreement": "Please read and agree to the agreement",
"privacy_policy": "Privacy Policy",
"private_team_id_of_user": "User's ID",
Expand All @@ -145,6 +154,9 @@
"quit_workspace_tips": "Confirm leaving workspace?",
"read_all": "Read All",
"read_and_agree": "Please read and agree to the agreement below",
"realNameVerification": "Real Name Verification",
"realName_verification": "Real Name Verification",
"realname_info": "RealName",
"receive_tips": "{{managerName}} invite you join in {{teamName}} as {{role}}",
"recharge_amount": "Recharge Amount",
"redirecting_to_homepage_in_3_seconds": "Redirecting to homepage in 3 seconds",
Expand Down Expand Up @@ -201,4 +213,4 @@
"you_can_view_fees_through_the_fee_center": "You can view fees through the fee center",
"you_have_not_purchased_the_license": "You have not purchased the License",
"yuan": "Yuan"
}
}
22 changes: 17 additions & 5 deletions frontend/desktop/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"delete_account_caution": "资源一旦删除,将不可恢复。因此,在执行以上操作前,请务必做好数据备份工作",
"delete_account_tips": "将永久删除此账户及其所有内容",
"delete_account_title": "注销提示",
"deleteaccounttitle": "Sealos 将永久删除此账户。",
"deleteaccounttitle": "Sealos 将永久删除此账户。",
"deletemyaccount": "删除我的账号",
"deploy_an_application": "来部署一个应用吧~",
"description": "描述",
Expand Down Expand Up @@ -70,6 +70,8 @@
"healthy_pod": "健康 Pod: {{count}}",
"hello_welcome": "您好, 欢迎来到",
"help_you_enable_high_availability_database": "帮您启用高可用数据库",
"idCard": "身份证",
"idCard_invalid": "身份证格式不对",
"in_payment": "支付中 ...",
"in_time": "加入时间",
"insufficient_balance_tips": "您的账户目前存在未结清的款项,为了顺利完成账户注销流程,请先结清欠款。",
Expand Down Expand Up @@ -97,20 +99,23 @@
"member_list": "成员列表",
"memory": "内存",
"merge": "合并",
"merge_account_title": "账户已被绑定",
"merge_account_tips1": "您尝试绑定的账号已被其他用户使用。由于存在冲突的其他绑定方式,无法合并账户。",
"merge_account_tips2": "您尝试绑定的账号已被其他用户使用。您可以选择合并账户,以统一管理您的信息和设置。 在合并完成后,个人空间有可能转化为普通的工作空间,是否现在合并账户?",
"merge_account_tips2": "您尝试绑定的账号已被其他用户使用。您可以选择合并账户,以统一管理您的信息和设置。 在合并完成后,个人空间有可能转化为普通的工作空间,是否现在合并账户?",
"merge_account_title": "账户已被绑定",
"message_center": "消息中心",
"monitor": "监控",
"more_apps": "更多应用",
"name": "姓名",
"name_of_team": "工作空间名称",
"name_required": "姓名格式不对",
"new_email": "新电子邮箱",
"new_phone": "新手机号",
"newpassword": "新密码",
"next": "下一步",
"next_time": "下次吧",
"nickname": "昵称",
"no_apps_found": "未找到任何应​​用",
"no_realname_auth": "未实名认证",
"noworkspacecreated": "您还没有创建工作空间",
"official_account_login": "公众号登录",
"old_email": "旧电子邮箱",
Expand All @@ -119,17 +124,21 @@
"order_number": "订单号",
"password": "密码",
"password_login": "密码登录",
"password_mis_match": "密码不一致",
"password_tips": "密码为8位以上字符",
"passwordchangesuccess": "密码修改成功",
"password_mis_match": "密码不一致",
"pay_with_stripe": "Stripe 支付",
"pay_with_wechat": "微信支付",
"payment_result": "支付结果",
"payment_status": "支付状态",
"payment_successful": "支付成功",
"phone": "手机号",
"phone_invalid": "电话号码格式不正确",
"phone_number_tips": "手机号",
"phonechangesuccess": "手机号修改成功",
"placeholders_idCard": "请输入您的身份证号码",
"placeholders_name": "请输入您的姓名",
"placeholders_phone": "请输入您的电话号码",
"please_read_and_agree_to_the_agreement": "请阅读并同意协议",
"privacy_policy": "隐私政策",
"private_team_id_of_user": "用户ID",
Expand All @@ -141,6 +150,9 @@
"quit_workspace_tips": "确认要退出工作空间吗?",
"read_all": "全部已读",
"read_and_agree": "请阅读并同意下方协议",
"realNameVerification": "实名认证",
"realName_verification": "实名认证",
"realname_info": "实名信息",
"receive_tips": "{{managerName}} 邀请你到 {{teamName}} 成为 {{role}}",
"recharge_amount": "充值金额",
"redirecting_to_homepage_in_3_seconds": "3秒后跳回主页",
Expand Down Expand Up @@ -194,4 +206,4 @@
"you_can_view_fees_through_the_fee_center": "您可通过费用中心查看费用",
"you_have_not_purchased_the_license": "您还没有购买 License",
"yuan": "元"
}
}
8 changes: 8 additions & 0 deletions frontend/desktop/src/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const _UserInfo = (request: AxiosInstance) => () =>
any,
ApiResp<{
info: {
realName?: string;
userRestrictedLevel?: number;
uid: string;
createdAt: Date;
updatedAt: Date;
Expand Down Expand Up @@ -139,6 +141,10 @@ export const _mergeUser =
export const _deleteUser = (request: AxiosInstance) => () =>
request<never, ApiResp<RESOURCE_STATUS>>('/api/auth/delete');

export const _realNameAuthRequest =
(request: AxiosInstance) => (data: { name: string; phone: string; idCard: string }) =>
request.post<any, ApiResp<{ name: string }>>('/api/account/realNameAuth', data);

export const passwordExistRequest = _passwordExistRequest(request);
export const passwordLoginRequest = _passwordLoginRequest(request, (token) => {
useSessionStore.setState({ token });
Expand All @@ -160,3 +166,5 @@ export const unBindRequest = _oauthProviderUnbind(request);
export const signInRequest = _oauthProviderSignIn(request);
export const mergeUserRequest = _mergeUser(request);
export const deleteUserRequest = _deleteUser(request);

export const realNameAuthRequest = _realNameAuthRequest(request);
Loading
Loading