create-nara 1.0.12 → 1.0.13

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.

Potentially problematic release.


This version of create-nara might be problematic. Click here for more details.

package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-nara",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "CLI to scaffold NARA projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -12,12 +12,13 @@ export function registerAuthRoutes(app: NaraApp) {
12
12
  app.post('/api/auth/register', async (req, res) => {
13
13
  await auth.register(req, res);
14
14
  });
15
+ // Logout is public - just clears the cookie
16
+ app.post('/api/auth/logout', async (req, res) => {
17
+ await auth.logout(req, res);
18
+ });
15
19
 
16
- // Protected routes (middleware cast needed due to hyper-express typing)
20
+ // Protected API routes (Bearer token)
17
21
  app.get('/api/auth/me', authMiddleware as any, async (req, res) => {
18
22
  await auth.me(req, res);
19
23
  });
20
- app.post('/api/auth/logout', authMiddleware as any, async (req, res) => {
21
- await auth.logout(req, res);
22
- });
23
24
  }
@@ -1,7 +1,7 @@
1
1
  <script lang="ts">
2
2
  import { fly, fade } from 'svelte/transition';
3
3
  import { page, router, inertia } from '@inertiajs/svelte';
4
- import { clickOutside } from '../components/helper';
4
+ import { clickOutside, Toast } from '../components/helper';
5
5
  import DarkModeToggle from '../components/DarkModeToggle.svelte';
6
6
 
7
7
  interface User {
@@ -22,20 +22,36 @@
22
22
  let scrollY = 0;
23
23
  let isMenuOpen: boolean = false;
24
24
 
25
- export let group: string;
25
+ export let group: string;
26
26
 
27
27
  $: scrolled = scrollY > 50;
28
28
 
29
29
  $: menuLinks = [
30
- { href: '/dashboard', label: 'Overview', group: 'dashboard', show: true },
30
+ { href: '/dashboard', label: 'Overview', group: 'dashboard', show: true },
31
31
  { href: '/users', label: 'Users', group: 'users', show: !!(user?.is_admin) },
32
32
  { href: '/profile', label: 'Profile', group: 'profile', show: !!user },
33
33
  ] as MenuLink[];
34
-
34
+
35
35
  $: visibleMenuLinks = menuLinks.filter((item) => item.show);
36
36
 
37
- function handleLogout(): void {
38
- router.post('/logout');
37
+ async function handleLogout(): Promise<void> {
38
+ try {
39
+ const response = await fetch('/api/auth/logout', {
40
+ method: 'POST',
41
+ headers: { 'Content-Type': 'application/json' }
42
+ });
43
+ const result = await response.json();
44
+
45
+ if (result.success) {
46
+ Toast(result.message || 'Logged out successfully', 'success');
47
+ router.visit(result.data?.redirect || '/login');
48
+ } else {
49
+ Toast(result.message || 'Logout failed', 'error');
50
+ }
51
+ } catch (err: unknown) {
52
+ const errorMessage = err instanceof Error ? err.message : 'Network error';
53
+ Toast(errorMessage, 'error');
54
+ }
39
55
  }
40
56
  </script>
41
57