Support nostr multiAuth
This commit is contained in:
parent
4c5e470caf
commit
aae0d3765a
|
@ -9,7 +9,7 @@ import NostrAuth from './nostr-auth'
|
|||
import LoginButton from './login-button'
|
||||
import { emailSchema } from '../lib/validate'
|
||||
|
||||
export function EmailLoginForm ({ text, callbackUrl }) {
|
||||
export function EmailLoginForm ({ text, callbackUrl, multiAuth }) {
|
||||
return (
|
||||
<Form
|
||||
initial={{
|
||||
|
@ -17,7 +17,7 @@ export function EmailLoginForm ({ text, callbackUrl }) {
|
|||
}}
|
||||
schema={emailSchema}
|
||||
onSubmit={async ({ email }) => {
|
||||
signIn('email', { email, callbackUrl })
|
||||
signIn('email', { email, callbackUrl, multiAuth })
|
||||
}}
|
||||
>
|
||||
<Input
|
||||
|
@ -57,7 +57,7 @@ export default function Login ({ providers, callbackUrl, error, multiAuth, text,
|
|||
}
|
||||
|
||||
if (router.query.type === 'nostr') {
|
||||
return <NostrAuth callbackUrl={callbackUrl} text={text} />
|
||||
return <NostrAuth callbackUrl={callbackUrl} text={text} multiAuth={multiAuth} />
|
||||
}
|
||||
|
||||
return (
|
||||
|
@ -76,7 +76,7 @@ export default function Login ({ providers, callbackUrl, error, multiAuth, text,
|
|||
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} />
|
||||
<EmailLoginForm text={text} callbackUrl={callbackUrl} multiAuth={multiAuth} />
|
||||
</div>
|
||||
)
|
||||
case 'Lightning':
|
||||
|
@ -103,7 +103,7 @@ export default function Login ({ providers, callbackUrl, error, multiAuth, text,
|
|||
className={`mt-2 ${styles.providerButton}`}
|
||||
key={provider.id}
|
||||
type={provider.id.toLowerCase()}
|
||||
onClick={() => signIn(provider.id, { callbackUrl })}
|
||||
onClick={() => signIn(provider.id, { callbackUrl, multiAuth })}
|
||||
text={`${text || 'Login'} with`}
|
||||
/>
|
||||
)
|
||||
|
|
|
@ -64,7 +64,7 @@ function NostrExplainer ({ text }) {
|
|||
)
|
||||
}
|
||||
|
||||
export function NostrAuth ({ text, callbackUrl }) {
|
||||
export function NostrAuth ({ text, callbackUrl, multiAuth }) {
|
||||
const [createAuth, { data, error }] = useMutation(gql`
|
||||
mutation createAuth {
|
||||
createAuth {
|
||||
|
@ -112,7 +112,8 @@ export function NostrAuth ({ text, callbackUrl }) {
|
|||
try {
|
||||
await signIn('nostr', {
|
||||
event: JSON.stringify(event),
|
||||
callbackUrl
|
||||
callbackUrl,
|
||||
multiAuth
|
||||
})
|
||||
} catch (e) {
|
||||
throw new Error('authorization failed', e)
|
||||
|
|
Loading…
Reference in New Issue