Commit 80d43b00 by Apple\Apple

Refactor: Conditionally render OAuth options in login and registration forms

This commit refactors the login and registration forms to enhance user experience by conditionally displaying OAuth-related UI elements.

- In `LoginForm.js` and `RegisterForm.js`:
    - The "Other login/registration options" button and the "or" divider are now only displayed if at least one OAuth provider is enabled in the system settings.
    - This change ensures a cleaner interface when no OAuth options are configured, preventing user confusion.
- In `RegisterForm.js`:
    - Changed `div` class from `relative` to `min-h-screen relative` to ensure the registration form an take up the entire screen height.
parent 618ed976
...@@ -442,21 +442,29 @@ const LoginForm = () => { ...@@ -442,21 +442,29 @@ const LoginForm = () => {
</div> </div>
</Form> </Form>
<Divider margin='12px' align='center'> {(status.github_oauth || status.oidc_enabled || status.wechat_login || status.linuxdo_oauth || status.telegram_oauth) && (
{t('或')} <>
</Divider> <Divider margin='12px' align='center'>
{t('或')}
</Divider>
<div className="mt-4 text-center">
<Button
theme="outline"
type="tertiary"
className="w-full !rounded-full"
size="large"
onClick={handleOtherLoginOptionsClick}
loading={otherLoginOptionsLoading}
>
{t('其他登录选项')}
</Button>
</div>
</>
)}
<div className="mt-4 text-center"> <div className="mt-6 text-center text-sm">
<Button <Text>{t('没有账户?')} <Link to="/register" className="text-blue-600 hover:text-blue-800 font-medium">{t('注册')}</Link></Text>
theme="outline"
type="tertiary"
className="w-full !rounded-full"
size="large"
onClick={handleOtherLoginOptionsClick}
loading={otherLoginOptionsLoading}
>
{t('其他登录选项')}
</Button>
</div> </div>
</div> </div>
</Card> </Card>
...@@ -503,7 +511,7 @@ const LoginForm = () => { ...@@ -503,7 +511,7 @@ const LoginForm = () => {
}; };
return ( return (
<div className="relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden"> <div className="min-h-screen relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden">
{/* 背景图片容器 - 放大并保持居中 */} {/* 背景图片容器 - 放大并保持居中 */}
<div <div
className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100" className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100"
......
...@@ -69,7 +69,7 @@ const PasswordResetConfirm = () => { ...@@ -69,7 +69,7 @@ const PasswordResetConfirm = () => {
} }
return ( return (
<div className="relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden"> <div className="min-h-screen relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden">
{/* 背景图片容器 - 放大并保持居中 */} {/* 背景图片容器 - 放大并保持居中 */}
<div <div
className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100" className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100"
......
...@@ -76,7 +76,7 @@ const PasswordResetForm = () => { ...@@ -76,7 +76,7 @@ const PasswordResetForm = () => {
} }
return ( return (
<div className="relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden"> <div className="min-h-screen relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden">
{/* 背景图片容器 - 放大并保持居中 */} {/* 背景图片容器 - 放大并保持居中 */}
<div <div
className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100" className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100"
......
...@@ -485,22 +485,26 @@ const RegisterForm = () => { ...@@ -485,22 +485,26 @@ const RegisterForm = () => {
</div> </div>
</Form> </Form>
<Divider margin='12px' align='center'> {(status.github_oauth || status.oidc_enabled || status.wechat_login || status.linuxdo_oauth || status.telegram_oauth) && (
{t('或')} <>
</Divider> <Divider margin='12px' align='center'>
{t('或')}
<div className="mt-4 text-center"> </Divider>
<Button
theme="outline" <div className="mt-4 text-center">
type="tertiary" <Button
className="w-full !rounded-full" theme="outline"
size="large" type="tertiary"
onClick={handleOtherRegisterOptionsClick} className="w-full !rounded-full"
loading={otherRegisterOptionsLoading} size="large"
> onClick={handleOtherRegisterOptionsClick}
{t('其他注册选项')} loading={otherRegisterOptionsLoading}
</Button> >
</div> {t('其他注册选项')}
</Button>
</div>
</>
)}
<div className="mt-6 text-center text-sm"> <div className="mt-6 text-center text-sm">
<Text>{t('已有账户?')} <Link to="/login" className="text-blue-600 hover:text-blue-800 font-medium">{t('登录')}</Link></Text> <Text>{t('已有账户?')} <Link to="/login" className="text-blue-600 hover:text-blue-800 font-medium">{t('登录')}</Link></Text>
...@@ -549,7 +553,7 @@ const RegisterForm = () => { ...@@ -549,7 +553,7 @@ const RegisterForm = () => {
}; };
return ( return (
<div className="relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden"> <div className="min-h-screen relative flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8 overflow-hidden">
<div <div
className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100" className="absolute inset-0 z-0 bg-cover bg-center scale-125 opacity-100"
style={{ style={{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment