feat(auth): add password reset #178
This commit was merged in pull request #180.
This commit is contained in:
@@ -1,17 +1,23 @@
|
||||
package auth
|
||||
|
||||
templ ChangePasswordComp() {
|
||||
templ ChangePasswordComp(isPasswordReset bool) {
|
||||
<form
|
||||
class="max-w-xl px-2 mx-auto flex flex-col gap-4 h-full justify-center"
|
||||
hx-post="/api/auth/change-password"
|
||||
if isPasswordReset {
|
||||
hx-post="/api/auth/reset-password-actual"
|
||||
} else {
|
||||
hx-post="/api/auth/change-password"
|
||||
}
|
||||
hx-swap="none"
|
||||
>
|
||||
<h2 class="text-6xl mb-10">
|
||||
Change Password
|
||||
</h2>
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<input type="password" class="grow" placeholder="Current Password" name="current-password"/>
|
||||
</label>
|
||||
if !isPasswordReset {
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<input type="password" class="grow" placeholder="Current Password" name="current-password"/>
|
||||
</label>
|
||||
}
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<input type="password" class="grow" placeholder="New Password" name="new-password"/>
|
||||
</label>
|
||||
|
||||
19
template/auth/reset_password.templ
Normal file
19
template/auth/reset_password.templ
Normal file
@@ -0,0 +1,19 @@
|
||||
package auth
|
||||
|
||||
templ ResetPasswordComp() {
|
||||
<form
|
||||
class="max-w-xl px-2 mx-auto flex flex-col gap-4 h-full justify-center"
|
||||
hx-post="/api/auth/reset-password"
|
||||
hx-swap="none"
|
||||
>
|
||||
<h2 class="text-6xl mb-10">
|
||||
Reset Password
|
||||
</h2>
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<input type="email" class="grow" placeholder="E-Mail" name="email"/>
|
||||
</label>
|
||||
<button class="btn btn-primary self-end">
|
||||
Request Password Reset
|
||||
</button>
|
||||
</form>
|
||||
}
|
||||
@@ -50,8 +50,9 @@ templ SignInOrUpComp(isSignIn bool) {
|
||||
</label>
|
||||
<div class="flex justify-end items-center gap-2">
|
||||
if isSignIn {
|
||||
<a href="/auth/reset-password" class="grow link text-gray-500 text-sm">Forgot Password?</a>
|
||||
<a href="/auth/signup" class="link text-gray-500 text-sm">Don't have an account? Sign Up</a>
|
||||
<button class="btn btn-primary self-end">
|
||||
<button class="btn btn-primary">
|
||||
Sign In
|
||||
</button>
|
||||
} else {
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"net/url"
|
||||
)
|
||||
|
||||
templ Register(mailCode string) {
|
||||
templ Register(token string) {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
@@ -15,7 +15,7 @@ templ Register(mailCode string) {
|
||||
</head>
|
||||
<body>
|
||||
<h4>Thank you for Sign Up!</h4>
|
||||
<p>Click <a href={ templ.URL(utils.BaseUrl + "/auth/verify-email?token=" + url.QueryEscape(mailCode)) }>here</a> to verify your account.</p>
|
||||
<p>Click <a href={ templ.URL(utils.BaseUrl + "/auth/verify-email?token=" + url.QueryEscape(token)) }>here</a> to verify your account.</p>
|
||||
<p>Kind regards</p>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
22
template/mail/reset-password.templ
Normal file
22
template/mail/reset-password.templ
Normal file
@@ -0,0 +1,22 @@
|
||||
package mail;
|
||||
|
||||
import (
|
||||
"me-fit/utils"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
templ ResetPassword(token string) {
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Reset Password</title>
|
||||
</head>
|
||||
<body>
|
||||
<h4>Reset your password</h4>
|
||||
<p>Click <a href={ templ.URL(utils.BaseUrl + "/auth/change-password?token=" + url.QueryEscape(token)) }>here</a> to change your password.</p>
|
||||
<p>Kind regards</p>
|
||||
</body>
|
||||
</html>
|
||||
}
|
||||
Reference in New Issue
Block a user