feat: add last used login method tracking and localization updates
This commit is contained in:
parent
8ab91cd157
commit
0fa7a8221c
|
|
@ -144,7 +144,7 @@ export const LoginModalContent = (props: LoginModalContentProps) => {
|
|||
<span>{t("login.continueWith", { provider: provider.name })}</span>
|
||||
{lastMethod === key && (
|
||||
<div className="absolute -right-2 -top-2 rounded-xl bg-accent px-2 py-0.5 text-sm text-white">
|
||||
Last used
|
||||
{t("login.lastUsed")}
|
||||
</div>
|
||||
)}
|
||||
</MotionButtonBase>
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ export const {
|
|||
changePassword,
|
||||
forgetPassword,
|
||||
getAccountInfo,
|
||||
getLastUsedLoginMethod,
|
||||
getProviders,
|
||||
getSession,
|
||||
linkSocial,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
import { UserAvatar } from "@client/components/ui/user-avatar"
|
||||
import { loginHandler, oneTimeToken, signOut, twoFactor } from "@client/lib/auth"
|
||||
import {
|
||||
getLastUsedLoginMethod,
|
||||
loginHandler,
|
||||
oneTimeToken,
|
||||
signOut,
|
||||
twoFactor,
|
||||
} from "@client/lib/auth"
|
||||
import { openInFollowApp } from "@client/lib/helper"
|
||||
import { queryClient } from "@client/lib/query-client"
|
||||
import { useSession } from "@client/query/auth"
|
||||
|
|
@ -66,6 +72,17 @@ export function Login() {
|
|||
const [callbackUrl, setCallbackUrl] = useState<string>()
|
||||
const callbackUrlWithScheme = callbackUrl ? `${DEEPLINK_SCHEME}${callbackUrl}` : undefined
|
||||
|
||||
const [lastMethod, setLastMethod] = useState<string | null>(null)
|
||||
useEffect(() => {
|
||||
let lastMethodValue = getLastUsedLoginMethod()
|
||||
if (lastMethodValue === "email") {
|
||||
lastMethodValue = "credential"
|
||||
}
|
||||
if (lastMethodValue) {
|
||||
setLastMethod(lastMethodValue)
|
||||
}
|
||||
}, [lastMethod])
|
||||
|
||||
const handleOpenApp = useCallback(async () => {
|
||||
const callbackUrl = await getCallbackUrl()
|
||||
if (!callbackUrl) return
|
||||
|
|
@ -168,7 +185,7 @@ export function Login() {
|
|||
loginHandler(key, "app")
|
||||
}
|
||||
}}
|
||||
className="center relative w-full gap-2 rounded-xl border p-2.5 pl-5 font-semibold duration-200 hover:bg-material-medium"
|
||||
className="center relative w-full gap-2 rounded-xl border py-3 pl-5 font-semibold duration-200 hover:bg-material-medium"
|
||||
>
|
||||
<img
|
||||
className={cn(
|
||||
|
|
@ -179,6 +196,11 @@ export function Login() {
|
|||
src={isDark ? provider.iconDark64 || provider.icon64 : provider.icon64}
|
||||
/>
|
||||
<span>{t("login.continueWith", { provider: provider.name })}</span>
|
||||
{lastMethod === key && (
|
||||
<div className="absolute -right-2 -top-2 rounded-xl bg-accent px-2 py-0.5 text-sm text-white">
|
||||
{t("login.lastUsed")}
|
||||
</div>
|
||||
)}
|
||||
</MotionButtonBase>
|
||||
))}
|
||||
</div>
|
||||
|
|
@ -219,6 +241,7 @@ export function Login() {
|
|||
openFailed,
|
||||
callbackUrl,
|
||||
isDark,
|
||||
lastMethod,
|
||||
])
|
||||
const Content = useMemo(() => {
|
||||
switch (true) {
|
||||
|
|
|
|||
|
|
@ -246,6 +246,7 @@
|
|||
"login.enter_token": "Enter authorization token to continue",
|
||||
"login.forget_password.note": "Forgot your password?",
|
||||
"login.have_account": "Already have an account? <strong>Sign in</strong>",
|
||||
"login.lastUsed": "Last used",
|
||||
"login.no_account": "Don't have an account? <strong>Sign up</strong>",
|
||||
"login.or": "OR",
|
||||
"login.password": "Password",
|
||||
|
|
|
|||
|
|
@ -244,6 +244,7 @@
|
|||
"login.enter_token": "输入授权令牌以继续",
|
||||
"login.forget_password.note": "忘记了密码?",
|
||||
"login.have_account": "已有账户?<strong>登录</strong>",
|
||||
"login.lastUsed": "上次使用",
|
||||
"login.no_account": "没有账户?<strong>注册</strong>",
|
||||
"login.or": "或",
|
||||
"login.password": "密码",
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
"login.forget_password.note": "Forgot your password?",
|
||||
"login.forget_password.success": "Email has been sent successfully",
|
||||
"login.have_account": "Already have an account? <strong>Sign in</strong>",
|
||||
"login.lastUsed": "Last used",
|
||||
"login.logInTo": "Sign in to",
|
||||
"login.logInWithEmail": "Sign in with email",
|
||||
"login.new_password.label": "New Password",
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
"login.forget_password.note": "忘记了密码?",
|
||||
"login.forget_password.success": "邮件已成功发送。",
|
||||
"login.have_account": "已有账户?<strong>登录</strong>",
|
||||
"login.lastUsed": "上次使用",
|
||||
"login.logInTo": "登录 ",
|
||||
"login.logInWithEmail": "使用邮件地址登录",
|
||||
"login.new_password.label": "新密码",
|
||||
|
|
|
|||
Loading…
Reference in New Issue