-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show but disable unavailable auth methods
- Loading branch information
Showing
3 changed files
with
33 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,8 +8,11 @@ import { LightningAuthWithExplainer } from './lightning-auth' | |
import { NostrAuthWithExplainer } from './nostr-auth' | ||
import LoginButton from './login-button' | ||
import { emailSchema } from '@/lib/validate' | ||
import { OverlayTrigger, Tooltip } from 'react-bootstrap' | ||
|
||
export function EmailLoginForm ({ text, callbackUrl, multiAuth }) { | ||
const disabled = multiAuth | ||
|
||
return ( | ||
<Form | ||
initial={{ | ||
|
@@ -26,8 +29,9 @@ export function EmailLoginForm ({ text, callbackUrl, multiAuth }) { | |
placeholder='[email protected]' | ||
required | ||
autoFocus | ||
disabled={disabled} | ||
/> | ||
<SubmitButton variant='secondary' className={styles.providerButton}>{text || 'Login'} with Email</SubmitButton> | ||
<SubmitButton disabled={disabled} variant='secondary' className={styles.providerButton}>{text || 'Login'} with Email</SubmitButton> | ||
</Form> | ||
) | ||
} | ||
|
@@ -74,10 +78,16 @@ export default function Login ({ providers, callbackUrl, multiAuth, error, text, | |
switch (provider.name) { | ||
case 'Email': | ||
return ( | ||
<div className='w-100' key={provider.id}> | ||
<div className='mt-2 text-center text-muted fw-bold'>or</div> | ||
<EmailLoginForm text={text} callbackUrl={callbackUrl} multiAuth={multiAuth} /> | ||
</div> | ||
<OverlayTrigger | ||
placement='bottom' | ||
overlay={multiAuth ? <Tooltip>not available for account switching yet</Tooltip> : <></>} | ||
trigger={['hover', 'focus']} | ||
> | ||
<div className='w-100' key={provider.id}> | ||
<div className='mt-2 text-center text-muted fw-bold'>or</div> | ||
<EmailLoginForm text={text} callbackUrl={callbackUrl} multiAuth={multiAuth} /> | ||
</div> | ||
</OverlayTrigger> | ||
) | ||
case 'Lightning': | ||
case 'Slashtags': | ||
|
@@ -99,13 +109,22 @@ export default function Login ({ providers, callbackUrl, multiAuth, error, text, | |
) | ||
default: | ||
return ( | ||
<LoginButton | ||
className={`mt-2 ${styles.providerButton}`} | ||
key={provider.id} | ||
type={provider.id.toLowerCase()} | ||
onClick={() => signIn(provider.id, { callbackUrl, multiAuth })} | ||
text={`${text || 'Login'} with`} | ||
/> | ||
<OverlayTrigger | ||
placement='bottom' | ||
overlay={multiAuth ? <Tooltip>not available for account switching yet</Tooltip> : <></>} | ||
trigger={['hover', 'focus']} | ||
> | ||
<div className='w-100'> | ||
<LoginButton | ||
className={`mt-2 ${styles.providerButton}`} | ||
key={provider.id} | ||
type={provider.id.toLowerCase()} | ||
onClick={() => signIn(provider.id, { callbackUrl, multiAuth })} | ||
text={`${text || 'Login'} with`} | ||
disabled={multiAuth} | ||
/> | ||
</div> | ||
</OverlayTrigger> | ||
) | ||
} | ||
})} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters