Skip to content

Commit a9154f8

Browse files
authored
fix invaild (#5118)
1 parent 56ffcb8 commit a9154f8

File tree

28 files changed

+485
-366
lines changed

28 files changed

+485
-366
lines changed

frontend/desktop/public/locales/en/common.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@
108108
"log_in": "Log In",
109109
"log_out": "Log Out",
110110
"login_to_your_account": "Login to your account",
111+
"login_with_github": "Login with Github",
112+
"login_with_google": "Login with Google",
113+
"login_with_oauth2": "login with OAuth2.0",
114+
"login_with_wechat": "Login with Wechat",
111115
"manage_team": "Manage Workspace",
112116
"member_list": "Member List",
113117
"memory": "Memory",
@@ -191,6 +195,7 @@
191195
"remaining_time": "Remaining Time: ",
192196
"remove": "Remove",
193197
"remove_member_tips": "Determine that you want to remove the member?",
198+
"rename": "Rename",
194199
"scan_with_wechat": "Scan with WeChat",
195200
"sealos_copilot": "Sealos Copilot",
196201
"sealos_document": "Sealos Document",
@@ -233,6 +238,5 @@
233238
"you_can_use_the_kubectl_command_directly_from_the_terminal": "You can use the kubectl command directly from the terminal",
234239
"you_can_view_fees_through_the_fee_center": "You can view fees through the fee center",
235240
"you_have_not_purchased_the_license": "You have not purchased the License",
236-
"yuan": "Yuan",
237-
"rename": "Rename"
241+
"yuan": "Yuan"
238242
}

frontend/desktop/public/locales/zh/common.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@
104104
"log_in": "登录",
105105
"log_out": "登出",
106106
"login_to_your_account": "登录您的帐户",
107+
"login_with_github": "Github 登录",
108+
"login_with_google": "Google 登录",
109+
"login_with_oauth2": "OAuth2.0 登录",
110+
"login_with_wechat": "Wechat 登录",
107111
"manage_team": "管理工作空间",
108112
"member_list": "成员列表",
109113
"memory": "内存",
@@ -187,6 +191,7 @@
187191
"remaining_time": "剩余激活时间: ",
188192
"remove": "移除",
189193
"remove_member_tips": "确认要移除该成员?",
194+
"rename": "重命名",
190195
"scan_with_wechat": "微信扫码支付",
191196
"sealos_copilot": "Sealos 小助理",
192197
"search_apps": "搜索应用",
@@ -226,6 +231,5 @@
226231
"you_can_use_the_kubectl_command_directly_from_the_terminal": "您可通过终端直接使用 kubectl 命令",
227232
"you_can_view_fees_through_the_fee_center": "您可通过费用中心查看费用",
228233
"you_have_not_purchased_the_license": "您还没有购买 License",
229-
"yuan": "",
230-
"rename": "重命名"
234+
"yuan": ""
231235
}

frontend/desktop/src/components/account/AccountCenter/AuthModifyList.tsx

+10-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { useConfigStore } from '@/stores/config';
22
import useSessionStore, { OauthAction } from '@/stores/session';
33
import { OauthProvider } from '@/types/user';
4-
import { Text, Image, Center } from '@chakra-ui/react';
4+
import { Center, Image, Text } from '@chakra-ui/react';
55
import { useTranslation } from 'next-i18next';
66
import router from 'next/router';
77
import { useMemo } from 'react';
8-
import { ConfigItem } from './ConfigItem';
98
import { BINDING_STATE_MODIFY_BEHAVIOR, BindingModifyButton } from './BindingModifyButton';
9+
import { ConfigItem } from './ConfigItem';
1010

1111
export function AuthModifyList({
1212
isOnlyOne,
@@ -34,17 +34,19 @@ export function AuthModifyList({
3434
<T extends OauthAction>({
3535
url,
3636
provider,
37-
clientId
37+
clientId,
38+
proxyAddress
3839
}: {
3940
url: string;
4041
provider: OauthProvider;
4142
clientId: string;
43+
proxyAddress?: string;
4244
}) =>
4345
(action: T) => {
4446
const state = generateState(action);
4547
setProvider(provider);
46-
if (conf.proxyAddress) {
47-
const target = new URL(conf.proxyAddress);
48+
if (proxyAddress) {
49+
const target = new URL(proxyAddress);
4850
const callback = new URL(conf.callbackURL);
4951
target.searchParams.append(
5052
'oauthProxyState',
@@ -69,6 +71,7 @@ export function AuthModifyList({
6971
return actionCbGen({
7072
provider: 'GITHUB',
7173
clientId: githubConf.clientID,
74+
proxyAddress: githubConf?.proxyAddress,
7275
url: `https://github.com/login/oauth/authorize?client_id=${githubConf?.clientID}&redirect_uri=${conf?.callbackURL}&scope=user:email%20read:user`
7376
})(action);
7477
}
@@ -83,6 +86,7 @@ export function AuthModifyList({
8386
return actionCbGen({
8487
provider: 'WECHAT',
8588
clientId: wechatConf.clientID,
89+
proxyAddress: wechatConf?.proxyAddress,
8690
url: `https://open.weixin.qq.com/connect/qrconnect?appid=${wechatConf?.clientID}&redirect_uri=${conf?.callbackURL}&response_type=code&scope=snsapi_login&#wechat_redirect`
8791
})(action);
8892
}
@@ -99,6 +103,7 @@ export function AuthModifyList({
99103
return actionCbGen({
100104
provider: 'GOOGLE',
101105
clientId: googleConf.clientID,
106+
proxyAddress: googleConf?.proxyAddress,
102107
url: `https://accounts.google.com/o/oauth2/v2/auth?client_id=${googleConf.clientID}&redirect_uri=${conf.callbackURL}&response_type=code&scope=${scope}&include_granted_scopes=true`
103108
})(action);
104109
}

frontend/desktop/src/components/account/AccountCenter/index.tsx

+57-54
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,39 @@
1+
import { UserInfo } from '@/api/auth';
2+
import PasswordModify from '@/components/account/AccountCenter/PasswordModify';
3+
import { useConfigStore } from '@/stores/config';
4+
import useSessionStore from '@/stores/session';
5+
import { ValueOf } from '@/types';
16
import {
7+
Badge,
8+
Center,
29
Flex,
3-
Text,
10+
HStack,
11+
IconButton,
12+
IconButtonProps,
13+
Image,
414
Modal,
515
ModalBody,
616
ModalCloseButton,
717
ModalContent,
8-
ModalOverlay,
9-
useDisclosure,
10-
IconButton,
11-
IconButtonProps,
1218
ModalHeader,
19+
ModalOverlay,
1320
Spinner,
14-
Image,
15-
HStack,
16-
VStack,
17-
Center,
18-
Badge
21+
Text,
22+
useDisclosure,
23+
VStack
1924
} from '@chakra-ui/react';
20-
import { useMemo, useState } from 'react';
25+
import { CloseIcon, LeftArrowIcon, SettingIcon } from '@sealos/ui';
2126
import { useQuery } from '@tanstack/react-query';
22-
import useSessionStore from '@/stores/session';
2327
import { useTranslation } from 'next-i18next';
24-
import { SettingIcon, LeftArrowIcon, CloseIcon } from '@sealos/ui';
25-
import { UserInfo } from '@/api/auth';
26-
import PasswordModify from '@/components/account/AccountCenter/PasswordModify';
27-
import { PhoneBind, EmailBind } from './SmsModify/SmsBind';
28-
import { PhoneUnBind, EmailUnBind } from './SmsModify/SmsUnbind';
29-
import { PhoneChange, EmailChange } from './SmsModify/SmsChange';
30-
import { BindingModifyButton, BINDING_STATE_MODIFY_BEHAVIOR } from './BindingModifyButton';
31-
import { ConfigItem } from './ConfigItem';
28+
import { useMemo, useState } from 'react';
29+
import { RealNameAuthForm } from '../RealNameModal';
3230
import { AuthModifyList } from './AuthModifyList';
31+
import { BINDING_STATE_MODIFY_BEHAVIOR, BindingModifyButton } from './BindingModifyButton';
32+
import { ConfigItem } from './ConfigItem';
3333
import DeleteAccount from './DeleteAccountModal';
34-
import { ValueOf } from '@/types';
35-
import { RealNameAuthForm } from '../RealNameModal';
36-
import { useConfigStore } from '@/stores/config';
34+
import { EmailBind, PhoneBind } from './SmsModify/SmsBind';
35+
import { EmailChange, PhoneChange } from './SmsModify/SmsChange';
36+
import { EmailUnBind, PhoneUnBind } from './SmsModify/SmsUnbind';
3737
enum _PageState {
3838
INDEX = 0
3939
// WECHAT_BIND,
@@ -68,6 +68,7 @@ const PageState = Object.assign(
6868
export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
6969
const { commonConfig } = useConfigStore();
7070
const { session } = useSessionStore((s) => s);
71+
const conf = useConfigStore();
7172
const { t } = useTranslation();
7273
const logo = '/images/default-user.svg';
7374
const { isOpen, onOpen, onClose } = useDisclosure();
@@ -236,7 +237,7 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
236237
}
237238
/>
238239
)}
239-
{providerState.PASSWORD.isBinding && (
240+
{conf.authConfig?.idp.password.enabled && providerState.PASSWORD.isBinding && (
240241
<ConfigItem
241242
LeftElement={<Text>{t('common:password')}</Text>}
242243
RightElement={
@@ -252,40 +253,42 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
252253
}
253254
/>
254255
)}
255-
<ConfigItem
256-
LeftElement={<Text>{t('common:phone')}</Text>}
257-
RightElement={
258-
<>
259-
<Text>
260-
{providerState.PHONE.isBinding
261-
? providerState.PHONE.id.replace(/(\d{3})\d+(\d{4})/, '$1****$2')
262-
: t('common:unbound')}
263-
</Text>
264-
<Flex gap={'5px'}>
265-
<BindingModifyButton
266-
modifyBehavior={
267-
providerState.PHONE.isBinding
268-
? BINDING_STATE_MODIFY_BEHAVIOR.CHANGE_BINDING
269-
: BINDING_STATE_MODIFY_BEHAVIOR.BINDING
270-
}
271-
onClick={() => {
272-
providerState.PHONE.isBinding
273-
? setPageState(PageState.PHONE_CHANGE_BIND)
274-
: setPageState(PageState.PHONE_BIND);
275-
}}
276-
/>
277-
{providerState.PHONE.isBinding && providerState.total > 1 && (
256+
{conf.authConfig?.idp.sms.enabled && (
257+
<ConfigItem
258+
LeftElement={<Text>{t('common:phone')}</Text>}
259+
RightElement={
260+
<>
261+
<Text>
262+
{providerState.PHONE.isBinding
263+
? providerState.PHONE.id.replace(/(\d{3})\d+(\d{4})/, '$1****$2')
264+
: t('common:unbound')}
265+
</Text>
266+
<Flex gap={'5px'}>
278267
<BindingModifyButton
279-
modifyBehavior={BINDING_STATE_MODIFY_BEHAVIOR.UNBINDING}
268+
modifyBehavior={
269+
providerState.PHONE.isBinding
270+
? BINDING_STATE_MODIFY_BEHAVIOR.CHANGE_BINDING
271+
: BINDING_STATE_MODIFY_BEHAVIOR.BINDING
272+
}
280273
onClick={() => {
281-
setPageState(PageState.PHONE_UNBIND);
274+
providerState.PHONE.isBinding
275+
? setPageState(PageState.PHONE_CHANGE_BIND)
276+
: setPageState(PageState.PHONE_BIND);
282277
}}
283278
/>
284-
)}
285-
</Flex>
286-
</>
287-
}
288-
/>
279+
{providerState.PHONE.isBinding && providerState.total > 1 && (
280+
<BindingModifyButton
281+
modifyBehavior={BINDING_STATE_MODIFY_BEHAVIOR.UNBINDING}
282+
onClick={() => {
283+
setPageState(PageState.PHONE_UNBIND);
284+
}}
285+
/>
286+
)}
287+
</Flex>
288+
</>
289+
}
290+
/>
291+
)}
289292
<ConfigItem
290293
LeftElement={<Text>{t('common:email')}</Text>}
291294
RightElement={

0 commit comments

Comments
 (0)