feat: support login by given mail (#4991)

This commit is contained in:
Joel 2024-06-06 15:01:58 +08:00 committed by GitHub
parent da5f2e168a
commit efecdccf35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -39,11 +39,12 @@ const LocaleLayout = ({
data-api-prefix={process.env.NEXT_PUBLIC_API_PREFIX}
data-pubic-api-prefix={process.env.NEXT_PUBLIC_PUBLIC_API_PREFIX}
data-public-edition={process.env.NEXT_PUBLIC_EDITION}
data-public-support-mail-login={process.env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN}
data-public-sentry-dsn={process.env.NEXT_PUBLIC_SENTRY_DSN}
data-public-maintenance-notice={process.env.NEXT_PUBLIC_MAINTENANCE_NOTICE}
data-public-site-about={process.env.NEXT_PUBLIC_SITE_ABOUT}
>
<Topbar/>
<Topbar />
<BrowerInitor>
<SentryInitor>
<I18nServer>{children}</I18nServer>

View File

@ -7,7 +7,7 @@ import useSWR from 'swr'
import Link from 'next/link'
import Toast from '../components/base/toast'
import style from './page.module.css'
import { IS_CE_EDITION, apiPrefix } from '@/config'
import { IS_CE_EDITION, SUPPORT_MAIL_LOGIN, apiPrefix } from '@/config'
import Button from '@/app/components/base/button'
import { login, oauth } from '@/service/common'
import { getPurifyHref } from '@/utils'
@ -62,6 +62,8 @@ function reducer(state: IState, action: IAction) {
const NormalForm = () => {
const { t } = useTranslation()
const useEmailLogin = IS_CE_EDITION || SUPPORT_MAIL_LOGIN
const router = useRouter()
const [state, dispatch] = useReducer(reducer, {
@ -150,7 +152,7 @@ const NormalForm = () => {
<div className="w-full mx-auto mt-8">
<div className="bg-white ">
{!IS_CE_EDITION && (
{!useEmailLogin && (
<div className="flex flex-col gap-3 mt-6">
<div className='w-full'>
<a href={getPurifyHref(`${apiPrefix}/oauth/login/github`)}>
@ -194,7 +196,7 @@ const NormalForm = () => {
)}
{
IS_CE_EDITION && <>
useEmailLogin && <>
{/* <div className="relative mt-6">
<div className="absolute inset-0 flex items-center" aria-hidden="true">
<div className="w-full border-t border-gray-300" />

View File

@ -33,6 +33,8 @@ export const PUBLIC_API_PREFIX: string = publicApiPrefix
const EDITION = process.env.NEXT_PUBLIC_EDITION || globalThis.document?.body?.getAttribute('data-public-edition') || 'SELF_HOSTED'
export const IS_CE_EDITION = EDITION === 'SELF_HOSTED'
export const SUPPORT_MAIL_LOGIN = !!(process.env.NEXT_PUBLIC_SUPPORT_MAIL_LOGIN || globalThis.document?.body?.getAttribute('data-public-support-mail-login'))
export const TONE_LIST = [
{
id: 1,