Skip to content

Commit

Permalink
Merge branch 'feat/auth-methods' into deploy/dev
Browse files Browse the repository at this point in the history
  • Loading branch information
douxc committed Oct 15, 2024
2 parents a05f249 + 1e11c64 commit f9047c4
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
4 changes: 2 additions & 2 deletions web/app/reset-password/set-password/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const ChangePasswordForm = () => {
<div className='flex flex-col md:w-[400px]'>
<div className="w-full mx-auto">
<h2 className="title-4xl-semi-bold text-text-primary">
{t('login.resetPassword')}
{t('login.changePassword')}
</h2>
<p className='mt-2 body-md-regular text-text-secondary'>
{t('login.changePasswordTip')}
Expand Down Expand Up @@ -139,7 +139,7 @@ const ChangePasswordForm = () => {
className='w-full'
onClick={handleChangePassword}
>
{t('common.operation.reset')}
{t('login.changePasswordBtn')}
</Button>
</div>
</div>
Expand Down
7 changes: 5 additions & 2 deletions web/app/signin/check-code/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@ export default function CheckCode() {
}
setIsLoading(true)
const ret = await emailLoginWithCode({ email, code, token })
localStorage.setItem('console_token', ret.data)
router.replace(invite_token ? `/signin/invite-settings?${searchParams.toString()}` : '/apps')
if (ret.result === 'success') {
localStorage.setItem('console_token', ret.data.access_token)
localStorage.setItem('refresh_token', ret.data.refresh_token)
router.replace(invite_token ? `/signin/invite-settings?${searchParams.toString()}` : '/apps')
}
}
catch (error) { console.error(error) }
finally {
Expand Down
4 changes: 4 additions & 0 deletions web/app/signin/components/mail-and-password-auth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@ import Link from 'next/link'
import { useState } from 'react'
import { useTranslation } from 'react-i18next'
import { useRouter, useSearchParams } from 'next/navigation'
import { useContext } from 'use-context-selector'
import Button from '@/app/components/base/button'
import Toast from '@/app/components/base/toast'
import { emailRegex } from '@/config'
import { login } from '@/service/common'
import Input from '@/app/components/base/input'
import I18NContext from '@/context/i18n'

type MailAndPasswordAuthProps = {
isInvite: boolean
}

export default function MailAndPasswordAuth({ isInvite }: MailAndPasswordAuthProps) {
const { t } = useTranslation()
const { locale } = useContext(I18NContext)
const router = useRouter()
const searchParams = useSearchParams()
const [showPassword, setShowPassword] = useState(false)
Expand All @@ -39,6 +42,7 @@ export default function MailAndPasswordAuth({ isInvite }: MailAndPasswordAuthPro
const loginData: Record<string, any> = {
email,
password,
language: locale,
remember_me: true,
}
if (isInvite)
Expand Down
3 changes: 2 additions & 1 deletion web/i18n/en-US/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ const translation = {
forgotPasswordDesc: 'Please enter your email address to reset your password. We will send you an email with instructions on how to reset your password.',
checkEmailForResetLink: 'Please check your email for a link to reset your password. If it doesn\'t appear within a few minutes, make sure to check your spam folder.',
passwordChanged: 'Sign in now',
changePassword: 'Change Password',
changePassword: 'Set a password',
changePasswordTip: 'Please enter a new password for your account',
changePasswordBtn: 'Set a password',
invalidToken: 'Invalid or expired token',
confirmPassword: 'Confirm Password',
confirmPasswordPlaceholder: 'Confirm your new password',
Expand Down
3 changes: 2 additions & 1 deletion web/i18n/zh-Hans/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ const translation = {
forgotPasswordDesc: '请输入您的电子邮件地址以重置密码。我们将向您发送一封电子邮件,包含如何重置密码的说明。',
checkEmailForResetLink: '请检查您的电子邮件以获取重置密码的链接。如果几分钟内没有收到,请检查您的垃圾邮件文件夹。',
passwordChanged: '立即登录',
changePassword: '更改密码',
changePassword: '设置密码',
changePasswordTip: '请输入您的新密码',
changePasswordBtn: '设置密码',
invalidToken: '无效或已过期的令牌',
confirmPassword: '确认密码',
confirmPasswordPlaceholder: '确认您的新密码',
Expand Down
2 changes: 1 addition & 1 deletion web/service/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ export const sendEMailLoginCode = (email: string, language = 'en-US') =>
post<CommonResponse & { data: string }>('/email-code-login', { body: { email, language } })

export const emailLoginWithCode = (data: { email: string;code: string;token: string }) =>
post<CommonResponse & { data: string }>('/email-code-login/validity', { body: data })
post<LoginResponse>('/email-code-login/validity', { body: data })

export const sendResetPasswordCode = (email: string, language = 'en-US') =>
post<CommonResponse & { data: string }>('/forgot-password', { body: { email, language } })
Expand Down

0 comments on commit f9047c4

Please sign in to comment.