-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from VortexExpansion/auth
Auth
Showing
29 changed files
with
1,813 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -288,4 +288,4 @@ <h2 class="c-heading--lv3-b -memberMenu">会員メニュー</h2> | |
</footer> | ||
|
||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -294,4 +294,4 @@ <h2 class="c-heading--lv3-b -memberMenu">会員メニュー</h2> | |
</footer> | ||
|
||
</body> | ||
</html> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -405,4 +405,4 @@ <h2 class="c-heading--lv3-b -memberMenu">会員メニュー</h2> | |
</footer> | ||
|
||
</body> | ||
</html> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,94 @@ | ||
export default function Login () { | ||
"use client"; | ||
|
||
import { useUser } from "@/components/common/userContext"; | ||
import { login } from "@/components/common/fetchData"; | ||
import { useRef } from "react"; | ||
import { useRouter } from "next/navigation"; | ||
import Link from "next/link"; | ||
import Breadcrumb from "@/components/common/Breadcrumb"; | ||
import PageTitle from "@/components/common/PageTitle"; | ||
import { getLabels } from "@/components/common/fetchData"; | ||
import AlertError from "@/components/ui/AlertError"; | ||
import { useState } from "react"; | ||
|
||
|
||
export default function Login() { | ||
const email = useRef(""); | ||
const password = useRef(""); | ||
const { user, loading, storeUser } = useUser(); | ||
const router = useRouter(); | ||
const contentDirectory = getLabels(); | ||
const content = contentDirectory.login; | ||
const [alert, setAlert] = useState(false); | ||
|
||
const handleChange = () => { | ||
setAlert(false); | ||
}; | ||
|
||
const handleLogin = async (event) => { | ||
event.preventDefault(); | ||
const user = await login(email.current.value, password.current.value); | ||
|
||
if (user) { | ||
setAlert(false); | ||
storeUser(user); | ||
router.push("member/mypage"); | ||
} | ||
else{ | ||
setAlert(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<main className="flex min-h-screen flex-col items-center justify-between p-24"> | ||
login page | ||
</main> | ||
) | ||
<div className="l-container"> | ||
<Breadcrumb paths={[{ label: content.text }]} /> | ||
<PageTitle content={content} /> | ||
<div className="l-container--small l-container--contents"> | ||
<div className="flex min-h-screen flex-col items-center justify-between p-24"> | ||
{loading ? ( | ||
<div>Loading...</div> | ||
) : user ? ( | ||
<div>You have already logged in.</div> | ||
) : ( | ||
<form className="c-form" onSubmit={handleLogin} onChange={handleChange}> | ||
<div className="c-form-group"> | ||
<label htmlFor="email" className="c-form-label"> | ||
メールアドレス | ||
</label> | ||
<input name="email" type="email" id="email" ref={email} /> | ||
</div> | ||
<div className="c-form-group"> | ||
<label htmlFor="password" className="c-form-label"> | ||
パスワード | ||
</label> | ||
<input | ||
name="password" | ||
type="password" | ||
id="password" | ||
ref={password} | ||
/> | ||
</div> | ||
<div className="c-form-group"> | ||
<button type="submit" className="c-button--primary u-width-100"> | ||
ログイン | ||
</button> | ||
</div> | ||
<div className="u-text-align-center u-mt-25"> | ||
<Link href="/register" className=""> | ||
会員登録 | ||
</Link> | ||
または | ||
<Link href="/reminder" className=""> | ||
パスワードをお忘れの方 | ||
</Link> | ||
</div> | ||
</form> | ||
)} | ||
|
||
</div> | ||
{alert && <AlertError message="メールアドレスまたはパスワードが間違っています。" />} | ||
</div> | ||
|
||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
"use client"; | ||
|
||
import Breadcrumb from "@/components/common/Breadcrumb"; | ||
import PageTitle from "@/components/common/PageTitle"; | ||
import { getLabels } from "@/components/common/fetchData"; | ||
import Link from "next/link"; | ||
import { useRef, useState } from "react"; | ||
import { register } from "@/components/common/fetchData"; | ||
import { useUser } from "@/components/common/userContext"; | ||
import { useRouter } from "next/navigation"; | ||
import AlertError from "@/components/ui/AlertError"; | ||
|
||
export default function Register() { | ||
const contentDirectory = getLabels(); | ||
const content = contentDirectory.register; | ||
const { user, loading, storeUser } = useUser(); | ||
const router = useRouter(); | ||
const [alert, setAlert] = useState(false); | ||
|
||
const name1 = useRef(""); | ||
const name2 = useRef(""); | ||
const email = useRef(""); | ||
const login_pwd = useRef(""); | ||
|
||
const handleChange = () => { | ||
setAlert(false); | ||
}; | ||
|
||
const handleRegister = async (event) => { | ||
event.preventDefault(); | ||
|
||
const user = await register( | ||
name1.current.value, | ||
name2.current.value, | ||
email.current.value, | ||
login_pwd.current.value | ||
); | ||
|
||
if (user) { | ||
setAlert(false); | ||
storeUser(user); | ||
router.push("member/mypage"); | ||
} else { | ||
setAlert(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<div className="l-container"> | ||
<Breadcrumb paths={[{ label: content.text }]} /> | ||
<PageTitle content={content} /> | ||
<div className="l-container--small l-container--contents"> | ||
<div className="c-form-group u-text-align-center"> | ||
<p className="c-text--small"> | ||
<span className="c-form-label__required">*</span>は必須項目です。 | ||
</p> | ||
</div> | ||
<form className="c-form" onSubmit={handleRegister} onChange={handleChange}> | ||
<div className="c-form-group"> | ||
<label htmlFor="name1" className="c-form-label"> | ||
名前(姓) | ||
</label> | ||
<span className="c-form-label__required">*</span> | ||
<input name="name1" type="text" id="name1" ref={name1} /> | ||
</div> | ||
<div className="c-form-group"> | ||
<label htmlFor="name2" className="c-form-label"> | ||
名前(名) | ||
</label> | ||
<input name="name2" type="text" id="name2" ref={name2} /> | ||
</div> | ||
<div className="c-form-group"> | ||
<label htmlFor="email" className="c-form-label"> | ||
メールアドレス | ||
</label> | ||
<input name="email" type="email" ref={email} /> | ||
</div> | ||
<div className="c-form-group"> | ||
<div className="u-display-flex"> | ||
<div className="u-display-flex-grow-1"> | ||
<label htmlFor="login_pwd" className="c-form-label"> | ||
パスワード | ||
</label> | ||
<span className="c-form-label__required u-ml-5">*</span> | ||
</div> | ||
<p className="u-ma-0 c-text--small">半角英数8文字以上</p> | ||
</div> | ||
<input | ||
name="login_pwd" | ||
type="password" | ||
id="login_pwd" | ||
ref={login_pwd} | ||
/> | ||
</div> | ||
<div className="c-form-group"> | ||
<button type="submit" className="c-button--primary u-width-100"> | ||
登録 | ||
</button> | ||
</div> | ||
<div className="c-form-group u-text-align-center"> | ||
すでに会員の方は | ||
<Link href="/login" className="nuxt-link-active"> | ||
ログイン | ||
</Link> | ||
</div> | ||
<p className="c-text--small u-mt-25"> | ||
続行することで<Link href="#">利用規約</Link>及び | ||
<Link href="/privacy">プライバシーポリシー</Link> | ||
に同意したこととなります。 | ||
</p> | ||
</form> | ||
{alert && <AlertError message="エントリー内容を再度ご確認ください。" />} | ||
</div> | ||
</div> | ||
); | ||
} |
Oops, something went wrong.