Skip to content

Commit 9ea6e3e

Browse files
パスワードを最低8文字にする #26
1 parent d885306 commit 9ea6e3e

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"cSpell.words": [
33
"instanceof",
4+
"minlength",
45
"onfocus",
56
"sveltejs",
67
"sveltekit"

src/routes/register/+page.server.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@ export const load: PageServerLoad = async ({ locals }) => {
1515
export const actions: Actions = {
1616
default: async ({ request }) => {
1717
const data = await request.formData()
18-
const username = data.get('username') as string
19-
const email = data.get('email') as string
20-
const password = data.get('password') as string
18+
const username = data.get('username')?.toString() ?? ''
19+
const email = data.get('email')?.toString() ?? ''
20+
const password = data.get('password')?.toString() ?? ''
21+
const password_is_valid = password.length >= 8
2122

22-
if (!username || !email || !password) return invalid(404, { missing: true })
23+
if (!username || !email || !password_is_valid) return invalid(404, { missing: true })
2324

2425
try {
2526
await db.user.create({

src/routes/register/+page.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
bind:this={username_element}
2828
/>
2929
<input type="email" name="email" placeholder="email" required />
30-
<input type="password" name="password" placeholder="Password" required />
30+
<input type="password" name="password" placeholder="Password" required minlength="8" />
3131

3232
{#if form?.missing}<p class="error">Username, email and password is required.</p>{/if}
3333
{#if form?.user_exists}<p class="error">Username or email is used.</p>{/if}

0 commit comments

Comments
 (0)