feat(auth): hide password login when disable_password_auth is set (#438) (#121)

Thank yWhen the backend resource endpoint reports disable_password_auth, the login
view hides the username/password form, the 'or' divider and the 'Create new
account' button, leaving only the configured SSO button — so SSO-only
instances present a clean login.

Auth options render only once the resource query has settled, so the password
form never flashes before being hidden (no FOUC) on SSO-only instances.

Also drops a dead setUserProfile(user) call in the post-auth effect (the
symbol was removed earlier, leaving a no-undef that broke lint on this file);
the profile now comes from useUserProfile().

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Louis-Michel Couture
2026-08-03 00:36:05 -04:00
committed by GitHub
parent 778ae72777
commit a05f8dc4a4

View File

@@ -105,7 +105,7 @@ const LoginView = () => {
setChildName('')
setPassword('')
}
const { data: resource } = useResource()
const { data: resource, isLoading: resourceLoading } = useResource()
const { showError } = useNotification()
const { isAuthenticated, login: authLogin, user } = useAuth()
const Navigate = useNavigate()
@@ -411,6 +411,10 @@ const LoginView = () => {
const showSocialLogin = import.meta.env.VITE_IS_SELF_HOSTED !== 'true'
const hasSocialOptions =
showSocialLogin || Boolean(resource?.identity_provider?.client_id)
// On SSO-only instances the password form, its divider and the signup link
// are hidden. Wait for the resource query to settle first so the form never
// flashes before being hidden.
const showPasswordAuth = !resourceLoading && !resource?.disable_password_auth
return (
<AuthShell
@@ -477,7 +481,7 @@ const LoginView = () => {
Use a different account
</Button>
</Box>
) : (
) : showPasswordAuth ? (
<Box
component='form'
onSubmit={handleSubmit}
@@ -554,9 +558,11 @@ const LoginView = () => {
{loginType === 'sub' ? 'Sign in as sub account' : 'Sign in'}
</AuthSubmitButton>
</Box>
)}
) : null}
{hasSocialOptions && <AuthDivider>or continue with</AuthDivider>}
{hasSocialOptions && (userProfile || showPasswordAuth) && (
<AuthDivider>or continue with</AuthDivider>
)}
<Box sx={{ display: 'flex', flexDirection: 'column', gap: 1.5 }}>
{showSocialLogin && !Capacitor.isNativePlatform() && (
@@ -644,24 +650,26 @@ const LoginView = () => {
)}
</Box>
{!userProfile && !resource?.is_user_creation_disabled && (
<Typography
level='body-sm'
sx={{ mt: 3, textAlign: 'center', color: 'text.secondary' }}
>
Don&apos;t have an account?{' '}
<Link
component='button'
type='button'
{!userProfile &&
showPasswordAuth &&
!resource?.is_user_creation_disabled && (
<Typography
level='body-sm'
fontWeight={600}
underline='hover'
onClick={() => Navigate('/signup')}
sx={{ mt: 3, textAlign: 'center', color: 'text.secondary' }}
>
Create one
</Link>
</Typography>
)}
Don&apos;t have an account?{' '}
<Link
component='button'
type='button'
level='body-sm'
fontWeight={600}
underline='hover'
onClick={() => Navigate('/signup')}
>
Create one
</Link>
</Typography>
)}
<MFAVerificationModal
open={mfaModalOpen}