Skip to content

Commit d1f5d62

Browse files
authored
Merge pull request #15 from soranjiro/fix/no-auth-handling
Fix/no auth handling
2 parents a0bb058 + f7d31cf commit d1f5d62

12 files changed

Lines changed: 733 additions & 757 deletions

File tree

apps/api/src/routes/auth.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ auth.post('/verify', async (c) => {
3535
auth.post('/password', async (c) => {
3636
const { shioriId, password }: PasswordAuthRequest = await c.req.json();
3737

38-
if (!shioriId || !password) {
38+
if (!shioriId) {
3939
return c.json({
4040
success: false,
41-
error: { code: 'INVALID_INPUT', message: 'shioriId and password are required' }
41+
error: { code: 'INVALID_INPUT', message: 'shioriId is required' }
4242
}, 400);
4343
}
4444

@@ -52,13 +52,19 @@ auth.post('/password', async (c) => {
5252
}, 404);
5353
}
5454

55-
if (itinerary.password !== password) {
55+
// If itinerary has a password, verify it
56+
if (itinerary.password && itinerary.password !== password) {
5657
return c.json({
5758
success: false,
5859
error: { code: 'UNAUTHORIZED', message: 'Invalid password' }
5960
}, 401);
6061
}
6162

63+
// If itinerary has no password, allow access (password can be anything or empty)
64+
if (!itinerary.password) {
65+
// No check needed
66+
}
67+
6268
const token = await generateToken(shioriId, c.env.JWT_SECRET);
6369

6470
return c.json({

apps/web/src/lib/themes/ai-generated/ItineraryView.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,14 @@
9999
}
100100
101101
if (!itinerary.password) {
102-
hasEditPermission = true;
102+
try {
103+
const token = await authApi.authenticateWithPassword(itinerary.id, "");
104+
auth.setToken(itinerary.id, itinerary.title, token);
105+
hasEditPermission = true;
106+
} catch (e) {
107+
console.error("Failed to authenticate without password", e);
108+
alert("認証に失敗しました");
109+
}
103110
return;
104111
}
105112

apps/web/src/lib/themes/minimal/ItineraryView.svelte

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,14 @@
101101
}
102102
103103
if (!itinerary.password) {
104-
hasEditPermission = true;
104+
try {
105+
const token = await authApi.authenticateWithPassword(itinerary.id, "");
106+
auth.setToken(itinerary.id, itinerary.title, token);
107+
hasEditPermission = true;
108+
} catch (e) {
109+
console.error("Failed to authenticate without password", e);
110+
alert("認証に失敗しました");
111+
}
105112
return;
106113
}
107114

apps/web/src/lib/themes/standard-autumn/ItineraryView.svelte

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -149,10 +149,17 @@
149149
}
150150
}
151151
152-
// パスワードが設定されていない場合は即座に編集モードに切り替え
152+
// パスワードが設定されていない場合は、空パスワードで認証してトークンを取得
153153
if (!itinerary.password) {
154-
hasEditPermission = true;
155-
showSettingsMenu = false;
154+
try {
155+
const token = await authApi.authenticateWithPassword(itinerary.id, "");
156+
auth.setToken(itinerary.id, itinerary.title, token);
157+
hasEditPermission = true;
158+
showSettingsMenu = false;
159+
} catch (e) {
160+
console.error("Failed to authenticate without password", e);
161+
alert("認証に失敗しました");
162+
}
156163
return;
157164
}
158165
@@ -472,7 +479,7 @@
472479
<span>Calendar</span>
473480
</button> -->
474481

475-
<div style="position: relative;">
482+
<div class="standard-autumn-btn-wrapper">
476483
<button
477484
class="standard-autumn-bottom-btn"
478485
title={hasEditPermission
@@ -509,7 +516,7 @@
509516
</button>
510517
</div>
511518
{#if hasEditPermission}
512-
<div style="position: relative;">
519+
<div class="standard-autumn-btn-wrapper">
513520
<button
514521
class="standard-autumn-bottom-btn"
515522
title="設定"
@@ -555,19 +562,16 @@
555562
</div>
556563
{/if}
557564
{#if showThemeSelect}
558-
<div
559-
style="position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); background: var(--standard-autumn-card-bg); border: 1px solid var(--standard-autumn-border); border-radius: 8px; box-shadow: 0 2px 8px rgba(0,0,0,0.08); padding: 0.5rem 1rem; z-index: 200; min-width: 180px; max-width: calc(100vw - 2rem); margin-bottom: 0.5rem;"
560-
>
565+
<div class="standard-autumn-theme-select-popup">
561566
<label
562567
for="theme-select"
563-
style="font-size: 0.95rem; color: var(--standard-autumn-text); margin-bottom: 0.5rem; display: block;"
564-
>テーマを選択</label
568+
class="standard-autumn-theme-select-label">テーマを選択</label
565569
>
566570
<select
567571
id="theme-select"
568572
value={selectedThemeId}
569573
onchange={handleThemeChange}
570-
style="width: 100%; font-size: 1rem; padding: 0.3rem; border-radius: 4px; border: 1px solid var(--standard-autumn-border); background: #fff; color: var(--standard-autumn-text);"
574+
class="standard-autumn-theme-select-input"
571575
>
572576
{#each themes as theme}
573577
<option value={theme.id}>{theme.name}</option>
@@ -750,8 +754,7 @@
750754
onclick={() => {
751755
showShareDialog = false;
752756
}}
753-
class="standard-autumn-btn standard-autumn-btn-secondary"
754-
style="width: 100%; margin-top: 0.5rem;"
757+
class="standard-autumn-btn standard-autumn-btn-secondary standard-autumn-btn-full"
755758
>
756759
キャンセル
757760
</button>

apps/web/src/lib/themes/standard-autumn/StepList.svelte

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -354,42 +354,42 @@
354354
<div class="standard-autumn-step-content">
355355
<div class="standard-autumn-step-title">
356356
{step.title}
357-
<div class="standard-autumn-step-actions">
358-
<button
359-
onclick={() => startEdit(step)}
360-
class="standard-autumn-btn-icon"
361-
title="編集"
362-
aria-label="編集"
363-
disabled={!hasEditPermission}
364-
>
365-
<svg
366-
xmlns="http://www.w3.org/2000/svg"
367-
viewBox="0 0 24 24"
368-
fill="currentColor"
357+
{#if hasEditPermission}
358+
<div class="standard-autumn-step-actions">
359+
<button
360+
onclick={() => startEdit(step)}
361+
class="standard-autumn-btn-icon"
362+
title="編集"
363+
aria-label="編集"
369364
>
370-
<path
371-
d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"
372-
/>
373-
</svg>
374-
</button>
375-
<button
376-
onclick={() => handleDelete(step.id)}
377-
class="standard-autumn-btn-icon"
378-
title="削除"
379-
aria-label="削除"
380-
disabled={!hasEditPermission}
381-
>
382-
<svg
383-
xmlns="http://www.w3.org/2000/svg"
384-
viewBox="0 0 24 24"
385-
fill="currentColor"
365+
<svg
366+
xmlns="http://www.w3.org/2000/svg"
367+
viewBox="0 0 24 24"
368+
fill="currentColor"
369+
>
370+
<path
371+
d="M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z"
372+
/>
373+
</svg>
374+
</button>
375+
<button
376+
onclick={() => handleDelete(step.id)}
377+
class="standard-autumn-btn-icon"
378+
title="削除"
379+
aria-label="削除"
386380
>
387-
<path
388-
d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
389-
/>
390-
</svg>
391-
</button>
392-
</div>
381+
<svg
382+
xmlns="http://www.w3.org/2000/svg"
383+
viewBox="0 0 24 24"
384+
fill="currentColor"
385+
>
386+
<path
387+
d="M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6v12zM19 4h-3.5l-1-1h-5l-1 1H5v2h14V4z"
388+
/>
389+
</svg>
390+
</button>
391+
</div>
392+
{/if}
393393
</div>
394394
{#if step.location}
395395
<div class="standard-autumn-step-location">

apps/web/src/lib/themes/standard-autumn/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ const fallTheme: Theme = {
1919
layout: 'single',
2020
colorScheme: 'light',
2121
customColors: {
22-
primary: '#DFB89A',
23-
secondary: '#F7E3CC',
24-
background: '#FEF6EC',
25-
text: '#333333',
26-
accent: '#8b5e3c'
22+
primary: '#a93529',
23+
secondary: '#e6b422',
24+
background: '#fcf9f2',
25+
text: '#4a3b32',
26+
accent: '#d4762c'
2727
}
2828
},
2929
components: {

0 commit comments

Comments
 (0)