mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-22 06:39:39 +02:00
Centralize auth messages
This commit is contained in:
parent
40c6c4b756
commit
2adf2de190
8 changed files with 23 additions and 19 deletions
6
app/helpers/auth_messages_helper.rb
Normal file
6
app/helpers/auth_messages_helper.rb
Normal file
|
@ -0,0 +1,6 @@
|
|||
module AuthMessagesHelper
|
||||
def auth_messages(form = nil)
|
||||
render "shared/auth_messages", flash: flash,
|
||||
errors: form&.object&.errors&.full_messages || []
|
||||
end
|
||||
end
|
|
@ -18,12 +18,6 @@
|
|||
</head>
|
||||
|
||||
<body class="h-full">
|
||||
<% flash.each do |type, msg| %>
|
||||
<div>
|
||||
<%= msg %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="flex flex-col justify-center min-h-full px-6 py-12">
|
||||
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-md">
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
%>
|
||||
|
||||
<%= form_with url: password_reset_path(token: params[:token]), html: {class: 'space-y-6'} do |form| %>
|
||||
<%= auth_messages form %>
|
||||
|
||||
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
|
||||
<%= form.label :password, class: 'block text-sm font-medium text-gray-700' %>
|
||||
|
@ -17,4 +18,4 @@
|
|||
<div>
|
||||
<%= form.submit "Reset Password", class: 'flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
%>
|
||||
|
||||
<%= form_with url: password_reset_path, html: {class: 'space-y-6'} do |form| %>
|
||||
<%= auth_messages form %>
|
||||
|
||||
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
|
||||
<%= form.label :email, class: 'block text-sm font-medium text-gray-700' %>
|
||||
<%= form.email_field :email, autofocus: false, autocomplete: "email", required: 'required', placeholder: 'you@example.com', class: 'p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
|
||||
|
@ -11,4 +13,4 @@
|
|||
<div>
|
||||
<%= form.submit "Reset password", class: 'flex justify-center w-full px-4 py-3 text-sm font-medium text-white bg-black rounded-xl hover:bg-black focus:outline-none focus:ring-2 focus:ring-gray-200 shadow' %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
|
@ -1,11 +1,7 @@
|
|||
<h1>Update Password</h1>
|
||||
|
||||
<%= form_with model: current_user, url: password_path do |form| %>
|
||||
<% if form.object.errors.any? %>
|
||||
<% form.object.errors.full_messages.each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= auth_messages form %>
|
||||
|
||||
<div>
|
||||
<%= form.label :password_challenge, "Current Password" %>
|
||||
|
|
|
@ -3,11 +3,7 @@
|
|||
%>
|
||||
|
||||
<%= form_with model: @user, url: registration_path, html: {class: 'space-y-6'} do |form| %>
|
||||
<% if form.object.errors.any? %>
|
||||
<% form.object.errors.full_messages.each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= auth_messages form %>
|
||||
|
||||
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
|
||||
<%= form.label :email, class: 'block text-sm font-medium text-gray-700' %>
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
|
||||
|
||||
<%= form_with url: session_path, html: {class: 'space-y-6'} do |form| %>
|
||||
<%= auth_messages form %>
|
||||
|
||||
<div class="relative p-4 border border-gray-100 bg-offwhite rounded-xl focus-within:bg-white focus-within:shadow focus-within:opacity-100">
|
||||
<%= form.label :email, "Email address", class: 'block text-sm font-medium text-gray-700' %>
|
||||
<%= form.email_field :email, autofocus: false, autocomplete: "email", required: 'required', placeholder: 'you@example.com', class: 'p-0 mt-1 bg-transparent border-none opacity-50 focus:outline-none focus:ring-0 focus-within:opacity-100 w-full' %>
|
||||
|
@ -25,4 +27,4 @@
|
|||
|
||||
<div class="mt-6 text-center">
|
||||
<p class="text-sm text-gray-600">Forgot your password? <%= link_to "Reset it", new_password_reset_path, class: 'font-medium text-candlelight-600 hover:text-candlelight-500' %></p>
|
||||
</div>
|
||||
</div>
|
||||
|
|
7
app/views/shared/_auth_messages.html.erb
Normal file
7
app/views/shared/_auth_messages.html.erb
Normal file
|
@ -0,0 +1,7 @@
|
|||
<% flash.each do |type, msg| %>
|
||||
<div><%= msg %></div>
|
||||
<% end %>
|
||||
|
||||
<% errors.each do |message| %>
|
||||
<div><%= message %></div>
|
||||
<% end %>
|
Loading…
Add table
Add a link
Reference in a new issue