Add password reset

Closes #15
This commit is contained in:
ricola 2025-06-07 18:38:33 -06:00
parent 84278741a5
commit fa4f77c365
14 changed files with 222 additions and 32 deletions

View file

@ -4,7 +4,7 @@
<p class="error"><%= @error %></p>
<% end %>
<form action="/login" method="POST">
<form action="/login" method="post">
<p>
<label for="email"><%= _("Email") %></label>
<input type="text" name="email">
@ -15,4 +15,5 @@
</p>
<button type="submit"><%= _("Login") %></button>
</form>
<a href="/signup"><%= _("Create account") %></a>
<p><a href="/signup"><%= _("Create account") %></a></p>
<p><a href="/reset"><%= _("Reset password") %></a></p>

9
views/reset.erb Normal file
View file

@ -0,0 +1,9 @@
<h1><%= _("Reset password") %></h1>
<form action="/reset" method="post">
<p>
<label for="email"><%= _("Email") %></label>
<input type="text" name="email">
</p>
<button type="submit"><%= _("Reset password") %></button>
</form>

21
views/reset_change.erb Normal file
View file

@ -0,0 +1,21 @@
<h1><%= _("Reset password") %></h1>
<% if @errors %>
<% @errors.each do |error| %>
<% if error.attribute == :password and error.type == :blank %>
<p class="error"><%= _("Specify a password.") %></p>
<% end %>
<% end %>
<% end %>
<form action="/reset/<%= params[:uuid] %>" method="post">
<p>
<label for="email"><%= _("Email") %></label>
<span><%= @user.email %></span>
</p>
<p>
<label for="password"><%= _("Password") %></label>
<input type="password" name="password" value="<%= params[:password] %>">
</p>
<button type="submit"><%= _("Reset password") %></button>
</form>

3
views/reset_email.erb Normal file
View file

@ -0,0 +1,3 @@
<%= _("Visit the following link to reset your password:") %>
<%= "#{settings.base_url}reset/#{@user.reset}" %>

5
views/reset_invalid.erb Normal file
View file

@ -0,0 +1,5 @@
<h1><%= _("Reset password") %></h1>
<p class="error"><%= _("This password reset link has expired or is invalid.") %></p>
<p><a href="/reset"><%= _("Try resetting your password again.") %></p>

6
views/reset_sent.erb Normal file
View file

@ -0,0 +1,6 @@
<h1><%= _("Reset password") %></h1>
<p><%= _("If an account exists for %{email}, you will get an email with a link
to reset your password.") % { email: params[:email] } %></p>
<p><%= _("If you don't receive the email, please check your spam folder.") %></p>