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

fix invaild #5118

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 6 additions & 2 deletions frontend/desktop/public/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
"log_in": "Log In",
"log_out": "Log Out",
"login_to_your_account": "Login to your account",
"login_with_github": "Login with Github",
"login_with_google": "Login with Google",
"login_with_oauth2": "login with OAuth2.0",
"login_with_wechat": "Login with Wechat",
"manage_team": "Manage Workspace",
"member_list": "Member List",
"memory": "Memory",
Expand Down Expand Up @@ -191,6 +195,7 @@
"remaining_time": "Remaining Time: ",
"remove": "Remove",
"remove_member_tips": "Determine that you want to remove the member?",
"rename": "Rename",
"scan_with_wechat": "Scan with WeChat",
"sealos_copilot": "Sealos Copilot",
"sealos_document": "Sealos Document",
Expand Down Expand Up @@ -233,6 +238,5 @@
"you_can_use_the_kubectl_command_directly_from_the_terminal": "You can use the kubectl command directly from the terminal",
"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",
"rename": "Rename"
"yuan": "Yuan"
}
8 changes: 6 additions & 2 deletions frontend/desktop/public/locales/zh/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@
"log_in": "登录",
"log_out": "登出",
"login_to_your_account": "登录您的帐户",
"login_with_github": "Github 登录",
"login_with_google": "Google 登录",
"login_with_oauth2": "OAuth2.0 登录",
"login_with_wechat": "Wechat 登录",
"manage_team": "管理工作空间",
"member_list": "成员列表",
"memory": "内存",
Expand Down Expand Up @@ -187,6 +191,7 @@
"remaining_time": "剩余激活时间: ",
"remove": "移除",
"remove_member_tips": "确认要移除该成员?",
"rename": "重命名",
"scan_with_wechat": "微信扫码支付",
"sealos_copilot": "Sealos 小助理",
"search_apps": "搜索应用",
Expand Down Expand Up @@ -226,6 +231,5 @@
"you_can_use_the_kubectl_command_directly_from_the_terminal": "您可通过终端直接使用 kubectl 命令",
"you_can_view_fees_through_the_fee_center": "您可通过费用中心查看费用",
"you_have_not_purchased_the_license": "您还没有购买 License",
"yuan": "元",
"rename": "重命名"
"yuan": "元"
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useConfigStore } from '@/stores/config';
import useSessionStore, { OauthAction } from '@/stores/session';
import { OauthProvider } from '@/types/user';
import { Text, Image, Center } from '@chakra-ui/react';
import { Center, Image, Text } from '@chakra-ui/react';
import { useTranslation } from 'next-i18next';
import router from 'next/router';
import { useMemo } from 'react';
import { ConfigItem } from './ConfigItem';
import { BINDING_STATE_MODIFY_BEHAVIOR, BindingModifyButton } from './BindingModifyButton';
import { ConfigItem } from './ConfigItem';

export function AuthModifyList({
isOnlyOne,
Expand Down Expand Up @@ -34,17 +34,19 @@ export function AuthModifyList({
<T extends OauthAction>({
url,
provider,
clientId
clientId,
proxyAddress
}: {
url: string;
provider: OauthProvider;
clientId: string;
proxyAddress?: string;
}) =>
(action: T) => {
const state = generateState(action);
setProvider(provider);
if (conf.proxyAddress) {
const target = new URL(conf.proxyAddress);
if (proxyAddress) {
const target = new URL(proxyAddress);
const callback = new URL(conf.callbackURL);
target.searchParams.append(
'oauthProxyState',
Expand All @@ -69,6 +71,7 @@ export function AuthModifyList({
return actionCbGen({
provider: 'GITHUB',
clientId: githubConf.clientID,
proxyAddress: githubConf?.proxyAddress,
url: `https://github.com/login/oauth/authorize?client_id=${githubConf?.clientID}&redirect_uri=${conf?.callbackURL}&scope=user:email%20read:user`
})(action);
}
Expand All @@ -83,6 +86,7 @@ export function AuthModifyList({
return actionCbGen({
provider: 'WECHAT',
clientId: wechatConf.clientID,
proxyAddress: wechatConf?.proxyAddress,
url: `https://open.weixin.qq.com/connect/qrconnect?appid=${wechatConf?.clientID}&redirect_uri=${conf?.callbackURL}&response_type=code&scope=snsapi_login&#wechat_redirect`
})(action);
}
Expand All @@ -99,6 +103,7 @@ export function AuthModifyList({
return actionCbGen({
provider: 'GOOGLE',
clientId: googleConf.clientID,
proxyAddress: googleConf?.proxyAddress,
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`
})(action);
}
Expand Down
111 changes: 57 additions & 54 deletions frontend/desktop/src/components/account/AccountCenter/index.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import { UserInfo } from '@/api/auth';
import PasswordModify from '@/components/account/AccountCenter/PasswordModify';
import { useConfigStore } from '@/stores/config';
import useSessionStore from '@/stores/session';
import { ValueOf } from '@/types';
import {
Badge,
Center,
Flex,
Text,
HStack,
IconButton,
IconButtonProps,
Image,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalOverlay,
useDisclosure,
IconButton,
IconButtonProps,
ModalHeader,
ModalOverlay,
Spinner,
Image,
HStack,
VStack,
Center,
Badge
Text,
useDisclosure,
VStack
} from '@chakra-ui/react';
import { useMemo, useState } from 'react';
import { CloseIcon, LeftArrowIcon, SettingIcon } from '@sealos/ui';
import { useQuery } from '@tanstack/react-query';
import useSessionStore from '@/stores/session';
import { useTranslation } from 'next-i18next';
import { SettingIcon, LeftArrowIcon, CloseIcon } from '@sealos/ui';
import { UserInfo } from '@/api/auth';
import PasswordModify from '@/components/account/AccountCenter/PasswordModify';
import { PhoneBind, EmailBind } from './SmsModify/SmsBind';
import { PhoneUnBind, EmailUnBind } from './SmsModify/SmsUnbind';
import { PhoneChange, EmailChange } from './SmsModify/SmsChange';
import { BindingModifyButton, BINDING_STATE_MODIFY_BEHAVIOR } from './BindingModifyButton';
import { ConfigItem } from './ConfigItem';
import { useMemo, useState } from 'react';
import { RealNameAuthForm } from '../RealNameModal';
import { AuthModifyList } from './AuthModifyList';
import { BINDING_STATE_MODIFY_BEHAVIOR, BindingModifyButton } from './BindingModifyButton';
import { ConfigItem } from './ConfigItem';
import DeleteAccount from './DeleteAccountModal';
import { ValueOf } from '@/types';
import { RealNameAuthForm } from '../RealNameModal';
import { useConfigStore } from '@/stores/config';
import { EmailBind, PhoneBind } from './SmsModify/SmsBind';
import { EmailChange, PhoneChange } from './SmsModify/SmsChange';
import { EmailUnBind, PhoneUnBind } from './SmsModify/SmsUnbind';
enum _PageState {
INDEX = 0
// WECHAT_BIND,
Expand Down Expand Up @@ -68,6 +68,7 @@ const PageState = Object.assign(
export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
const { commonConfig } = useConfigStore();
const { session } = useSessionStore((s) => s);
const conf = useConfigStore();
const { t } = useTranslation();
const logo = '/images/default-user.svg';
const { isOpen, onOpen, onClose } = useDisclosure();
Expand Down Expand Up @@ -236,7 +237,7 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
}
/>
)}
{providerState.PASSWORD.isBinding && (
{conf.authConfig?.idp.password.enabled && providerState.PASSWORD.isBinding && (
<ConfigItem
LeftElement={<Text>{t('common:password')}</Text>}
RightElement={
Expand All @@ -252,40 +253,42 @@ export default function Index(props: Omit<IconButtonProps, 'aria-label'>) {
}
/>
)}
<ConfigItem
LeftElement={<Text>{t('common:phone')}</Text>}
RightElement={
<>
<Text>
{providerState.PHONE.isBinding
? providerState.PHONE.id.replace(/(\d{3})\d+(\d{4})/, '$1****$2')
: t('common:unbound')}
</Text>
<Flex gap={'5px'}>
<BindingModifyButton
modifyBehavior={
providerState.PHONE.isBinding
? BINDING_STATE_MODIFY_BEHAVIOR.CHANGE_BINDING
: BINDING_STATE_MODIFY_BEHAVIOR.BINDING
}
onClick={() => {
providerState.PHONE.isBinding
? setPageState(PageState.PHONE_CHANGE_BIND)
: setPageState(PageState.PHONE_BIND);
}}
/>
{providerState.PHONE.isBinding && providerState.total > 1 && (
{conf.authConfig?.idp.sms.enabled && (
<ConfigItem
LeftElement={<Text>{t('common:phone')}</Text>}
RightElement={
<>
<Text>
{providerState.PHONE.isBinding
? providerState.PHONE.id.replace(/(\d{3})\d+(\d{4})/, '$1****$2')
: t('common:unbound')}
</Text>
<Flex gap={'5px'}>
<BindingModifyButton
modifyBehavior={BINDING_STATE_MODIFY_BEHAVIOR.UNBINDING}
modifyBehavior={
providerState.PHONE.isBinding
? BINDING_STATE_MODIFY_BEHAVIOR.CHANGE_BINDING
: BINDING_STATE_MODIFY_BEHAVIOR.BINDING
}
onClick={() => {
setPageState(PageState.PHONE_UNBIND);
providerState.PHONE.isBinding
? setPageState(PageState.PHONE_CHANGE_BIND)
: setPageState(PageState.PHONE_BIND);
}}
/>
)}
</Flex>
</>
}
/>
{providerState.PHONE.isBinding && providerState.total > 1 && (
<BindingModifyButton
modifyBehavior={BINDING_STATE_MODIFY_BEHAVIOR.UNBINDING}
onClick={() => {
setPageState(PageState.PHONE_UNBIND);
}}
/>
)}
</Flex>
</>
}
/>
)}
<ConfigItem
LeftElement={<Text>{t('common:email')}</Text>}
RightElement={
Expand Down
Loading
Loading