Skip to content

Commit

Permalink
Add sign up views, password recovery views
Browse files Browse the repository at this point in the history
  • Loading branch information
LuigiR0jas committed Jul 15, 2024
1 parent 73b535c commit 0068b79
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/controllers/password_resets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def create
).password_reset.deliver_later
end

redirect_to new_session_path, notice: t("controllers.password_resets.create.notice")
redirect_to post_submit_password_reset_path
end

def update
Expand Down
24 changes: 15 additions & 9 deletions app/views/password_resets/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<h1>Reset Your Password</h1>

<%= form_with model: @user, url: password_reset_path do |form| %>
<div>
<%= form.label :email %>
<%= form.email_field :email %>
<div class="flex flex-col items-center h-screen px-5 pt-10 bg-purple-dark">
<div class="flex flex-col w-full mb-6">
<h1 class="mb-4 text-4xl italic font-black text-white">Forgot Password</h1>
<p class="font-bold text-white">We'll send you a link to create a new password to the email address of your choice</p>
</div>

<div>
<%= form.submit "Reset password" %>
<div class="w-full">
<%= form_with model: @user, url: password_reset_path do |form| %>
<div class="mb-10">
<div class="flex flex-col w-full mb-6">
<%= form.label :email, class: "text-white italic font-bold mb-2" %>
<%= form.email_field :email, placeholder: "email@example.com", class: "bg-transparent border border-2 border-white rounded-md text-white placeholder-white", data: { test_id: "email_field" } %>
</div>

<%= form.submit "Send recovery email", class: "w-full bg-red py-4 text-white font-black italic rounded-[10px] uppercase", data: { test_id: "sign_up_button" } %>
<% end %>
</div>
<% end %>
</div>
8 changes: 8 additions & 0 deletions app/views/password_resets/post_submit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<div class="flex flex-col items-center h-screen px-5 pt-10 bg-purple-dark">
<div class="flex flex-col w-full mb-6">
<h1 class="mb-4 text-4xl italic font-black text-white">Check your inbox</h1>
<p class="font-bold text-white">We've sent you a link to recover your password to the email you provided.</p>
</div>

<%= link_to "Return to login", new_session_path, class: "w-full bg-red py-4 text-white text-center font-black italic rounded-[10px] uppercase", data: { test_id: "sign_up_button" } %>
</div>
50 changes: 28 additions & 22 deletions app/views/registrations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
<h1>Sign Up</h1>
<div class="flex flex-col items-center h-screen px-5 pt-10 bg-purple-dark">
<div class="flex flex-col w-full mb-6">
<h1 class="mb-4 text-4xl italic font-black text-white">Sign Up</h1>
</div>

<%= form_with model: @user, url: registration_path do |form| %>
<% if form.object.errors.any? %>
<% form.object.errors.full_messages.each do |message| %>
<div><%= message %></div>
<% end %>
<% end %>
<div class="w-full">
<%= form_with model: @user, url: registration_path do |form| %>
<% if form.object.errors.any? %>
<% form.object.errors.full_messages.each do |message| %>
<div><%= message %></div>
<% end %>
<% end %>

<div>
<%= form.label :email %>
<%= form.email_field :email, data: { test_id: "email_field" } %>
</div>
<div class="mb-10">
<div class="flex flex-col w-full mb-6">
<%= form.label :email, class: "text-white italic font-bold mb-2" %>
<%= form.email_field :email, placeholder: "email@example.com", class: "bg-transparent border border-2 border-white rounded-md text-white placeholder-white", data: { test_id: "email_field" } %>
</div>

<div>
<%= form.label :password %>
<%= form.password_field :password, data: { test_id: "password_field" } %>
</div>
<div class="flex flex-col mb-6">
<%= form.label :password, class: "text-white italic font-bold mb-2" %>
<%= form.password_field :password, placeholder: "Password", class: "bg-transparent border border-2 border-white rounded-md text-white placeholder-white", data: { test_id: "password_field" } %>
</div>

<div>
<%= form.label :password_confirmation %>
<%= form.password_field :password_confirmation, data: { test_id: "password_confirmation_field" } %>
</div>
<div class="flex flex-col">
<%= form.label :password_confirmation, class: "text-white italic font-bold mb-2" %>
<%= form.password_field :password_confirmation, placeholder: "You know how a strong password goes, right?", class: "bg-transparent border border-2 border-white rounded-md text-white placeholder-white", data: { test_id: "password_confirmation_field" } %>
</div>
</div>

<div>
<%= form.submit "Sign Up", data: { test_id: "sign_up_button" } %>
<%= form.submit "Sign Up", class: "w-full bg-red py-4 text-white font-black italic rounded-[10px] uppercase", data: { test_id: "sign_up_button" } %>
<% end %>
</div>
<% end %>
</div>
6 changes: 3 additions & 3 deletions app/views/sessions/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<div class="mb-10">
<div class="flex flex-col w-full mb-6">
<%= form.label :email, class: "text-white italic font-bold mb-2" %>
<%= form.email_field :email, placeholder: "email@example.com", class: "bg-transparent border border-2 border-white rounded-md text-white", data: { test_id: "email_field" } %>
<%= form.email_field :email, placeholder: "email@example.com", class: "bg-transparent border border-2 border-white rounded-md text-white" %>
</div>

<div class="flex flex-col">
<%= form.label :password, class: "text-white italic font-bold mb-2" %>
<%= form.password_field :password, placeholder: "Password", class: "bg-transparent border border-2 border-white rounded-md text-white", data: { test_id: "password_field" } %>
<%= form.password_field :password, placeholder: "Password", class: "bg-transparent border border-2 border-white rounded-md text-white" %>
</div>
</div>

Expand All @@ -24,7 +24,7 @@
<%= link_to "Sign up", new_registration_path, class: "font-black italic underline text-white" %>
</div>

<%= form.submit "Log in", class: "w-full bg-red py-4 text-white font-black italic rounded-[10px] uppercase", data: { test_id: "sign_in_button" } %>
<%= form.submit "Log in", class: "w-full bg-red py-4 text-white font-black italic rounded-[10px] uppercase" %>
<% end %>
</div>
</div>
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@
resource :registration, only: [:new, :create]
resource :session, only: [:new, :create, :destroy]
resource :password, only: [:edit, :update]
resource :password_reset, only: [:new, :create, :edit, :update]
resource :password_reset, only: [:new, :create, :edit, :update] do
get :post_submit
end
end

0 comments on commit 0068b79

Please sign in to comment.