Skip to content

Commit

Permalink
misc: fix logging in even when email isn't verified
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyphyn committed Sep 27, 2023
1 parent ac14708 commit cec0bbc
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "photon-lemmy",
"version": "1.12.2",
"version": "1.13.0",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down
17 changes: 12 additions & 5 deletions src/routes/signup/[instance]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
QuestionMarkCircle,
XCircle,
} from 'svelte-hero-icons'
import { instance as currentInstance } from '$lib/instance.js'
export let data
Expand Down Expand Up @@ -63,19 +64,25 @@
})
toast({
content: `Signed up.${
res.verify_email_sent ? ' A verification email was sent.' : ''
}`,
content: 'Signed up.',
type: 'success',
})
if (res?.jwt) {
if (res?.jwt && res.verify_email_sent) {
await setUser(res.jwt, $page.params.instance, username)
toast({ content: 'Successfully logged in.', type: 'success' })
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 {
throw new Error('Invalid credentials')
throw new Error('Failed to sign up.')
}
} catch (err) {
toast({
Expand Down

0 comments on commit cec0bbc

Please sign in to comment.