@alinsafawi/aegis-auth 0.2.4 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +21 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -23616,23 +23616,27 @@ export default function LoginPage() {
23616
23616
  setError('')
23617
23617
  setLoading(true)
23618
23618
 
23619
- const csrf = document.cookie
23620
- .split('; ')
23621
- .find((r) => r.startsWith('${appName.toLowerCase().replace(/[^a-z]/g, "")}_csrf='))
23622
- ?.split('=')[1]
23623
-
23624
- const res = await fetch('/api/auth/login', {
23625
- method: 'POST',
23626
- headers: { 'Content-Type': 'application/json', 'x-csrf-token': csrf ?? '' },
23627
- body: JSON.stringify({ identifier, password }),
23628
- })
23629
-
23630
- const data = await res.json()
23631
- setLoading(false)
23632
-
23633
- if (!res.ok) { setError(data.error ?? 'Login failed'); return }
23634
- if (data.requiresTwoFactor) { router.push('/two-factor'); return }
23635
- router.push(\`/\${data.role}/dashboard\`)
23619
+ try {
23620
+ const csrf = document.cookie
23621
+ .split('; ')
23622
+ .find((r) => r.startsWith('${appName.toLowerCase().replace(/[^a-z]/g, "")}_csrf='))
23623
+ ?.split('=')[1]
23624
+
23625
+ const res = await fetch('/api/auth/login', {
23626
+ method: 'POST',
23627
+ headers: { 'Content-Type': 'application/json', 'x-csrf-token': csrf ?? '' },
23628
+ body: JSON.stringify({ identifier, password }),
23629
+ })
23630
+
23631
+ const data = await res.json()
23632
+ if (!res.ok) { setError(data.error ?? 'Login failed'); return }
23633
+ if (data.requiresTwoFactor) { router.push('/two-factor'); return }
23634
+ router.push(\`/\${data.role}/dashboard\`)
23635
+ } catch {
23636
+ setError('Network error \u2014 please try again.')
23637
+ } finally {
23638
+ setLoading(false)
23639
+ }
23636
23640
  }
23637
23641
 
23638
23642
  return (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alinsafawi/aegis-auth",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "The shield your Next.js app deserves — full-stack auth in minutes",
5
5
  "bin": {
6
6
  "aegis-auth": "dist/index.js"