Skip to content

Commit ad07b1f

Browse files
authored
Merge pull request #1233 from AtCoder-NoviSteps/#1232
✨ Ensure easy access to guest account (#1232)
2 parents a4932e2 + e95fde2 commit ad07b1f

File tree

4 files changed

+38
-8
lines changed

4 files changed

+38
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
## 使い方
7171

7272
1. (初回のみ) ユーザ名とパスワードを入力して、アカウントを作成します。
73-
2. ログインします。お試し用のアカウント (ユーザ名: guest、パスワード: HelloGuest) を利用することもできます。
73+
2. ログインします。お試し用のアカウント (ユーザ名: guest、パスワード: Hell0Guest) を利用することもできます。
7474
3. 問題一覧で、グレードおよび問題を選び、回答欄の「更新」をクリックもしくはタップします。
7575
4. 該当する回答状況 (デフォルトは「未挑戦」)を選択し、「回答を更新」ボタンを押します。
7676

src/lib/components/AuthForm.svelte

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@
22
import { Card, Button, Label, Input } from 'flowbite-svelte';
33
44
// 必要なコンポーネントだけを読み込んで、コンパイルを時間を短縮
5-
// モジュールは読み込めているのに以下のエラーが発生するため、やむなく@ts-ignoreを使用
6-
// Cannot find module 'flowbite-svelte-icons/xxx.svelte' or its corresponding type declarations.ts(2307)
7-
// @ts-ignore
5+
import Checkbox from 'flowbite-svelte/Checkbox.svelte';
86
import UserOutlineSolid from 'flowbite-svelte-icons/UserCircleSolid.svelte';
9-
// @ts-ignore
107
import EyeOutline from 'flowbite-svelte-icons/EyeOutline.svelte';
11-
// @ts-ignore
128
import EyeSlashOutline from 'flowbite-svelte-icons/EyeSlashOutline.svelte';
139
1410
import MessageHelperWrapper from '$lib/components/MessageHelperWrapper.svelte';
1511
12+
import {
13+
GUEST_USER_NAME,
14+
GUEST_USER_PASSWORD,
15+
// GUEST_USER_PASSWORD_FOR_LOCAL,
16+
LOGIN_LABEL,
17+
} from '$lib/constants/forms';
18+
1619
// FIXME: 構造体に相当するものを利用した方が拡張・修正がしやすくなるかもしれせまん
1720
export let formProperties;
1821
export let title: string;
@@ -23,11 +26,26 @@
2326
2427
const { form, message, errors, submitting, enhance } = formProperties;
2528
29+
let isGuest: boolean = false;
30+
31+
$: if (isGuest) {
32+
$form.username = GUEST_USER_NAME;
33+
34+
// HACK: ローカル環境のパスワードは一時的に書き換えて対応している
35+
//
36+
// See:
37+
// src/lib/constants/forms.ts
38+
// $form.password = GUEST_USER_PASSWORD_FOR_LOCAL;
39+
$form.password = GUEST_USER_PASSWORD;
40+
} else {
41+
$form.username = '';
42+
$form.password = '';
43+
}
44+
2645
const UNFOCUSABLE = -1;
2746
let showPassword = false;
2847
</script>
2948

30-
<!-- TODO: ゲストユーザ(お試し用)としてログインできるようにする -->
3149
<!-- FIXME: コンポーネントが巨大になってきたと思われるので、分割しましょう -->
3250
<!-- TODO: containerのデフォルト値を設定できないか? -->
3351
<!-- See: -->
@@ -40,6 +58,10 @@
4058

4159
<MessageHelperWrapper message={$message} />
4260

61+
{#if title === LOGIN_LABEL}
62+
<Checkbox bind:checked={isGuest}>お試し用のアカウントを使う</Checkbox>
63+
{/if}
64+
4365
<!-- User name -->
4466
<div class="space-y-2">
4567
<Label for="username-in-auth-form">

src/lib/constants/forms.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
export const CREATE_ACCOUNT_LABEL: string = 'アカウントを作成';
22
export const LOGIN_LABEL: string = 'ログイン';
3+
4+
export const GUEST_USER_NAME: string = 'guest';
5+
6+
// Note: 2024年9月時点では、staging環境、production環境を優先
7+
// ローカル環境では書き換えて対応
8+
// TODO: ローカル環境とstaging環境、production環境では値が異なるため、切り替えられるようにする
9+
export const GUEST_USER_PASSWORD_FOR_LOCAL: string = 'Ch0kuda1';
10+
export const GUEST_USER_PASSWORD: string = 'Hell0Guest';

src/routes/about/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
<List tag="ol" class="text-gray-800 dark:text-gray-300 ml-6 space-y-1">
8888
<Li>(初回のみ) ユーザ名とパスワードを入力して、アカウントを作成します。</Li>
8989
<Li>
90-
ログインします。お試し用のアカウント (ユーザ名: guest、パスワード: HelloGuest)
90+
ログインします。お試し用のアカウント (ユーザ名: guest、パスワード: Hell0Guest)
9191
を利用することもできます。
9292
</Li>
9393
<Li>

0 commit comments

Comments
 (0)