Преглед изворни кода

Feat: change user email freezes limit (#22912)

Co-authored-by: Yansong Zhang <916125788@qq.com>
tags/1.7.1
KVOJJJin пре 3 месеци
родитељ
комит
d6b980a2dd
No account linked to committer's email address

+ 2
- 0
api/controllers/console/workspace/account.py Прегледај датотеку

parser = reqparse.RequestParser() parser = reqparse.RequestParser()
parser.add_argument("email", type=email, required=True, location="json") parser.add_argument("email", type=email, required=True, location="json")
args = parser.parse_args() args = parser.parse_args()
if AccountService.is_account_in_freeze(args["email"]):
raise AccountInFreezeError()
if not AccountService.check_email_unique(args["email"]): if not AccountService.check_email_unique(args["email"]):
raise EmailAlreadyInUseError() raise EmailAlreadyInUseError()
return {"result": "success"} return {"result": "success"}

+ 18
- 4
web/app/account/account-page/email-change-modal.tsx Прегледај датотеку

verifyEmail, verifyEmail,
} from '@/service/common' } from '@/service/common'
import { noop } from 'lodash-es' import { noop } from 'lodash-es'
import { asyncRunSafe } from '@/utils'
import type { ResponseError } from '@/service/fetch'


type Props = { type Props = {
show: boolean show: boolean
const [time, setTime] = useState<number>(0) const [time, setTime] = useState<number>(0)
const [stepToken, setStepToken] = useState<string>('') const [stepToken, setStepToken] = useState<string>('')
const [newEmailExited, setNewEmailExited] = useState<boolean>(false) const [newEmailExited, setNewEmailExited] = useState<boolean>(false)
const [unAvailableEmail, setUnAvailableEmail] = useState<boolean>(false)
const [isCheckingEmail, setIsCheckingEmail] = useState<boolean>(false) const [isCheckingEmail, setIsCheckingEmail] = useState<boolean>(false)


const startCount = () => { const startCount = () => {
email, email,
}) })
setNewEmailExited(false) setNewEmailExited(false)
setUnAvailableEmail(false)
} }
catch {
setNewEmailExited(true)
catch (e: any) {
if (e.status === 400) {
const [, errRespData] = await asyncRunSafe<ResponseError>(e.json())
const { code } = errRespData || {}
if (code === 'email_already_in_use')
setNewEmailExited(true)
if (code === 'account_in_freeze')
setUnAvailableEmail(true)
}
} }
finally { finally {
setIsCheckingEmail(false) setIsCheckingEmail(false)
placeholder={t('common.account.changeEmail.emailPlaceholder')} placeholder={t('common.account.changeEmail.emailPlaceholder')}
value={mail} value={mail}
onChange={e => handleNewEmailValueChange(e.target.value)} onChange={e => handleNewEmailValueChange(e.target.value)}
destructive={newEmailExited}
destructive={newEmailExited || unAvailableEmail}
/> />
{newEmailExited && ( {newEmailExited && (
<div className='body-xs-regular mt-1 py-0.5 text-text-destructive'>{t('common.account.changeEmail.existingEmail')}</div> <div className='body-xs-regular mt-1 py-0.5 text-text-destructive'>{t('common.account.changeEmail.existingEmail')}</div>
)} )}
{unAvailableEmail && (
<div className='body-xs-regular mt-1 py-0.5 text-text-destructive'>{t('common.account.changeEmail.unAvailableEmail')}</div>
)}
</div> </div>
<div className='mt-3 space-y-2'> <div className='mt-3 space-y-2'>
<Button <Button
disabled={!mail || newEmailExited || isCheckingEmail || !isValidEmail(mail)}
disabled={!mail || newEmailExited || unAvailableEmail || isCheckingEmail || !isValidEmail(mail)}
className='!w-full' className='!w-full'
variant='primary' variant='primary'
onClick={sendCodeToNewEmail} onClick={sendCodeToNewEmail}

+ 1
- 0
web/i18n/en-US/common.ts Прегледај датотеку

emailLabel: 'New email', emailLabel: 'New email',
emailPlaceholder: 'Enter a new email', emailPlaceholder: 'Enter a new email',
existingEmail: 'A user with this email already exists.', existingEmail: 'A user with this email already exists.',
unAvailableEmail: 'This email is temporarily unavailable.',
sendVerifyCode: 'Send verification code', sendVerifyCode: 'Send verification code',
continue: 'Continue', continue: 'Continue',
changeTo: 'Change to {{email}}', changeTo: 'Change to {{email}}',

+ 1
- 0
web/i18n/ja-JP/common.ts Прегледај датотеку

emailLabel: '新しいメール', emailLabel: '新しいメール',
emailPlaceholder: '新しいメールを入力してください', emailPlaceholder: '新しいメールを入力してください',
existingEmail: 'このメールアドレスのユーザーは既に存在します', existingEmail: 'このメールアドレスのユーザーは既に存在します',
unAvailableEmail: 'このメールアドレスは現在使用できません。',
sendVerifyCode: '確認コードを送信', sendVerifyCode: '確認コードを送信',
continue: '続行', continue: '続行',
changeTo: '{{email}} に変更', changeTo: '{{email}} に変更',

+ 1
- 0
web/i18n/zh-Hans/common.ts Прегледај датотеку

emailLabel: '新邮箱', emailLabel: '新邮箱',
emailPlaceholder: '输入新邮箱', emailPlaceholder: '输入新邮箱',
existingEmail: '该邮箱已存在', existingEmail: '该邮箱已存在',
unAvailableEmail: '该邮箱暂时无法使用。',
sendVerifyCode: '发送验证码', sendVerifyCode: '发送验证码',
continue: '继续', continue: '继续',
changeTo: '更改为 {{email}}', changeTo: '更改为 {{email}}',

Loading…
Откажи
Сачувај