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