From f2ebce0ef2ac9c9c4e994cb754f67f6fa8a3f465 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Sun, 19 Apr 2026 09:53:28 +0200 Subject: [PATCH] feat: Enhance login forms with last used authentication method --- apps/web/src/pages/auth/login.tsx | 116 +++++++++++++++++++----------- 1 file changed, 73 insertions(+), 43 deletions(-) diff --git a/apps/web/src/pages/auth/login.tsx b/apps/web/src/pages/auth/login.tsx index 608f808..bc21afc 100644 --- a/apps/web/src/pages/auth/login.tsx +++ b/apps/web/src/pages/auth/login.tsx @@ -23,7 +23,7 @@ import {NextSeo} from 'next-seo'; import Image from 'next/image'; import Link from 'next/link'; import {useRouter} from 'next/router'; -import React, {useState} from 'react'; +import React, {useEffect, useState} from 'react'; import {useForm} from 'react-hook-form'; import type {z} from 'zod'; @@ -57,8 +57,16 @@ export default function Login() { }, }); + const [lastUsed, setLastUsed] = useState<'email' | 'google' | 'github' | null>(null); const [errorMessage, setErrorMessage] = useState(null); const [showReset, setShowReset] = useState(false); + + useEffect(() => { + const stored = localStorage.getItem('plunk_last_auth_method'); + if (stored === 'email' || stored === 'google' || stored === 'github') { + setLastUsed(stored); + } + }, []); const [resetEmail, setResetEmail] = useState(''); const [resetStatus, setResetStatus] = useState<'idle' | 'loading' | 'success' | 'error'>('idle'); const [resetError, setResetError] = useState(null); @@ -82,6 +90,7 @@ export default function Login() { setErrorMessage('Email or password is incorrect'); } else { setErrorMessage(null); + localStorage.setItem('plunk_last_auth_method', 'email'); await userMutate(); await projectsMutate(); @@ -157,49 +166,65 @@ export default function Login() { <>
{oauthConfig.google && ( - +
+ + {lastUsed === 'google' && ( + + Last used + + )} +
)} {oauthConfig.github && ( - +
+ + {lastUsed === 'github' && ( + + Last used + + )} +
)}
@@ -219,7 +244,12 @@ export default function Login() { name="email" render={({field}) => ( - Email +
+ Email + {lastUsed === 'email' && ( + Last used + )} +