Add password reset service

This commit is contained in:
2024-09-12 07:33:10 -04:00
parent 56ce9fa2f8
commit 32f10ce40c
11 changed files with 539 additions and 38 deletions

98
templates/pwChange.gohtml Normal file
View File

@@ -0,0 +1,98 @@
<!doctype html>
<html>
{{template "head" .}}
<body class="min-h-screen bg-gray-100">
{{template "header".}}
<main class="px-6">
<div class="py-12 flex justify-center">
<div class="px-8 py-8 bg-white rounded shadow">
<h1 class="pt-4 pb-8 text-center text-3xl font-bold text-gray-900">
Reset your password
</h1>
<form action="/reset-pw" method="post">
<div class="hidden">
{{csrfField}}
</div>
<div class="py-2">
<label for="password" class="text-sm font-semibold text-gray-800"
>New password</label
>
<input
name="password"
id="password"
type="password"
placeholder="Password"
required
class="
w-full
px-3
py-2
border border-gray-300
placeholder-gray-500
text-gray-800
rounded
"
autofocus
/>
</div>
{{if .Token}}
<div class="hidden">
<input type="hidden" id="token" name="token" value="{{.Token}}" />
</div>
{{else}}
<div class="py-2">
<label for="token" class="text-sm font-semibold text-gray-800"
>Password Reset Token</label
>
<input
name="token"
id="token"
type="text"
placeholder="Check your email"
required
class="
w-full
px-3
py-2
border border-gray-300
placeholder-gray-500
text-gray-800
rounded
"
/>
</div>
{{end}}
<div class="py-4">
<button
type="submit"
class="
w-full
py-4
px-2
bg-indigo-600
hover:bg-indigo-700
text-white
rounded
font-bold
text-lg
"
>
Update password
</button>
</div>
<div class="py-2 w-full flex justify-between">
<p class="text-xs text-gray-500">
<a href="/signup" class="underline">Sign up</a>
</p>
<p class="text-xs text-gray-500">
<a href="/signin" class="underline">Sign in</a>
</p>
</div>
</form>
</div>
</div>
</main>
{{template "footer" .}}
</body>
</html>

74
templates/pwReset.gohtml Normal file
View File

@@ -0,0 +1,74 @@
<!doctype html>
<html>
{{template "head" .}}
<body class="min-h-screen bg-gray-100">
{{template "header".}}
<main class="px-6">
<div class="py-12 flex justify-center">
<div class="px-8 py-8 bg-white rounded shadow">
<h1 class="pt-4 pb-8 text-center text-3xl font-bold text-gray-900">
Forgot your password?
</h1>
<p class="text-sm text-gray-600 pb-4">No problem. Enter your email address and we'll send you a link to reset your password.</p>
<form action="/forgot-pw" method="post">
<div class="hidden">
{{csrfField}}
</div>
<div class="py-2">
<label for="email" class="text-sm font-semibold text-gray-800"
>Email Address</label
>
<input
name="email"
id="email"
type="email"
placeholder="Email address"
required
autocomplete="email"
class="
w-full
px-3
py-2
border border-gray-300
placeholder-gray-500
text-gray-800
rounded
"
value="{{.Email}}"
autofocus
/>
</div>
<div class="py-4">
<button
type="submit"
class="
w-full
py-4
px-2
bg-indigo-600
hover:bg-indigo-700
text-white
rounded
font-bold
text-lg
"
>
Reset password
</button>
</div>
<div class="py-2 w-full flex justify-between">
<p class="text-xs text-gray-500">
Need an account?
<a href="/signup" class="underline">Sign up</a>
</p>
<p class="text-xs text-gray-500">
<a href="/signin" class="underline">Remember your password?</a>
</p>
</div>
</form>
</div>
</div>
</main>
{{template "footer" .}}
</body>
</html>

View File

@@ -0,0 +1,18 @@
<!doctype html>
<html>
{{template "head" .}}
<body class="min-h-screen bg-gray-100">
{{template "header".}}
<main class="px-6">
<div class="py-12 flex justify-center">
<div class="px-8 py-8 bg-white rounded shadow">
<h1 class="pt-4 pb-8 text-center text-3xl font-bold text-gray-900">
Check your email
</h1>
<p class="text-sm text-gray-600 pb-4">An email has been sent to the email address {{.Email}} with instructions to reset your password.</p>
</div>
</div>
</main>
{{template "footer" .}}
</body>
</html>

View File

@@ -54,7 +54,7 @@
<a href="/signup" class="underline">Sign up</a>
</p>
<p class="text-xs text-gray-500">
<a href="/reset-pw" class="underline">Forgot your password?</a>
<a href="/forgot-pw" class="underline">Forgot your password?</a>
</p>
</div>
</form>

View File

@@ -41,7 +41,7 @@
<a href="/signin" class="underline">Sign in</a>
</p>
<p class="text-xs text-gray-500">
<a href="/reset-pw" class="underline">Forgot your password?</a>
<a href="/forgot-pw" class="underline">Forgot your password?</a>
</p>
</div>
</form>