misc: fix logging in even when email isn't verified
This commit is contained in:
1 parent
ac147086f1
commit
cec0bbc132
2 files changed
+13
-6
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "1.12.2",
|
"version": "1.13.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
QuestionMarkCircle,
|
QuestionMarkCircle,
|
||||||
XCircle,
|
XCircle,
|
||||||
} from 'svelte-hero-icons'
|
} from 'svelte-hero-icons'
|
||||||
|
import { instance as currentInstance } from '$lib/instance.js'
|
||||||
|
|
||||||
export let data
|
export let data
|
||||||
|
|
||||||
@@ -63,19 +64,25 @@
|
|||||||
})
|
})
|
||||||
|
|
||||||
toast({
|
toast({
|
||||||
content: `Signed up.${
|
content: 'Signed up.',
|
||||||
res.verify_email_sent ? ' A verification email was sent.' : ''
|
|
||||||
}`,
|
|
||||||
type: 'success',
|
type: 'success',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (res?.jwt) {
|
if (res?.jwt && res.verify_email_sent) {
|
||||||
await setUser(res.jwt, $page.params.instance, username)
|
await setUser(res.jwt, $page.params.instance, username)
|
||||||
|
|
||||||
toast({ content: 'Successfully logged in.', type: 'success' })
|
toast({ content: 'Successfully logged in.', type: 'success' })
|
||||||
goto('/')
|
goto('/')
|
||||||
|
} else if (res.verify_email_sent) {
|
||||||
|
currentInstance.set(instance)
|
||||||
|
toast({
|
||||||
|
content:
|
||||||
|
'A verification link was sent to your email. Verify your email, and then you can log in.',
|
||||||
|
type: 'info',
|
||||||
|
})
|
||||||
|
goto('/')
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Invalid credentials')
|
throw new Error('Failed to sign up.')
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
Reference in new issue
Block a user