Skip to content

Commit a290d13

Browse files
authored
chore: メールアドレスでログインできるようにした (#409)
* chore: メールアドレスでログインできるようにした * chore: fix e2e test account email * chore: change autoComplete type
1 parent 33a3e35 commit a290d13

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

app/lib/api/login.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import type {
55
import { createCookie } from "react-router";
66

77
export type LoginArgs = {
8-
name: string;
8+
email: string;
99
passphrase: string;
1010
};
1111

1212
export type ERROR_MESSAGES = "INVALID_CREDENTIALS" | "CONNECTION_FAILED";
1313

1414
export const login = async (
15-
{ name, passphrase }: LoginArgs,
15+
{ email, passphrase }: LoginArgs,
1616
basePath: string
1717
): Promise<
1818
| { error: ERROR_MESSAGES }
@@ -26,7 +26,7 @@ export const login = async (
2626
headers: {
2727
"Content-Type": "application/json",
2828
},
29-
body: JSON.stringify({ name, passphrase, captcha_token: "" }),
29+
body: JSON.stringify({ email, passphrase, captcha_token: "" }),
3030
});
3131

3232
if (!response.ok) {

app/routes/login.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ export const meta: MetaFunction = () => {
2626

2727
export const action = async ({ request, context }: ActionFunctionArgs) => {
2828
const formData = await request.formData();
29-
const name = formData.get("name") as string;
29+
const email = formData.get("email") as string;
3030
const passphrase = formData.get("passphrase") as string;
3131

3232
const basePath = (context.cloudflare.env as Env).API_BASE_URL;
33-
const res = await login({ name, passphrase }, basePath);
33+
const res = await login({ email, passphrase }, basePath);
3434
if ("error" in res) {
3535
const errorMessage =
3636
res.error === "INVALID_CREDENTIALS"
@@ -63,13 +63,13 @@ export default function Login() {
6363
</p>
6464

6565
<Form method="post" className={styles.loginForm}>
66-
<label htmlFor="name">Account name [required]</label>
66+
<label htmlFor="email">Email address [required]</label>
6767
<input
68-
type="text"
69-
id="name"
70-
name="name"
68+
type="email"
69+
id="email"
70+
name="email"
7171
required
72-
placeholder="@[email protected]"
72+
placeholder="[email protected]"
7373
autoComplete="username"
7474
/>
7575
<label htmlFor="password">Passphrase [required]</label>

tests/account.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { expect, test } from "@playwright/test";
22

33
test("has account info", async ({ page }) => {
44
await page.goto("/login");
5-
await page.locator("#name").fill("@john@example.com");
5+
await page.locator("#email").fill("testuser101@example.com");
66
await page.locator("#password").fill("じゃすた・いぐざんぽぅ");
77
await page.locator("#password + [type='submit']").click();
88
await page.waitForURL("/");

0 commit comments

Comments
 (0)