diff options
author | David Gay <david@davidgay.org> | 2021-04-25 13:07:25 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-04-25 13:07:25 -0400 |
commit | 8b517ea5ac6301bd513c18632aa34ce91545dd95 (patch) | |
tree | 7b4dc6f1e6d303ec6f5b02a27151c088bf5c72af | |
parent | 10f7bb7deb784be697aaff629d10b61d9cfe739d (diff) |
Adjust devise routes, views, and language
-rw-r--r-- | app/views/devise/confirmations/new.html.erb | 16 | ||||
-rw-r--r-- | app/views/devise/mailer/confirmation_instructions.html.erb | 5 | ||||
-rw-r--r-- | app/views/devise/mailer/email_changed.html.erb | 7 | ||||
-rw-r--r-- | app/views/devise/mailer/password_change.html.erb | 3 | ||||
-rw-r--r-- | app/views/devise/mailer/reset_password_instructions.html.erb | 8 | ||||
-rw-r--r-- | app/views/devise/mailer/unlock_instructions.html.erb | 7 | ||||
-rw-r--r-- | app/views/devise/passwords/edit.html.erb | 25 | ||||
-rw-r--r-- | app/views/devise/passwords/new.html.erb | 16 | ||||
-rw-r--r-- | app/views/devise/registrations/edit.html.erb | 43 | ||||
-rw-r--r-- | app/views/devise/registrations/new.html.erb | 29 | ||||
-rw-r--r-- | app/views/devise/sessions/new.html.erb | 26 | ||||
-rw-r--r-- | app/views/devise/shared/_error_messages.html.erb | 15 | ||||
-rw-r--r-- | app/views/devise/shared/_links.html.erb | 25 | ||||
-rw-r--r-- | app/views/devise/unlocks/new.html.erb | 16 | ||||
-rw-r--r-- | config/locales/devise.en.yml | 26 | ||||
-rw-r--r-- | config/routes.rb | 5 |
16 files changed, 259 insertions, 13 deletions
diff --git a/app/views/devise/confirmations/new.html.erb b/app/views/devise/confirmations/new.html.erb new file mode 100644 index 0000000..b12dd0c --- /dev/null +++ b/app/views/devise/confirmations/new.html.erb @@ -0,0 +1,16 @@ +<h2>Resend confirmation instructions</h2> + +<%= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + + <div class="field"> + <%= f.label :email %><br /> + <%= f.email_field :email, autofocus: true, autocomplete: "email", value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email) %> + </div> + + <div class="actions"> + <%= f.submit "Resend confirmation instructions" %> + </div> +<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/mailer/confirmation_instructions.html.erb b/app/views/devise/mailer/confirmation_instructions.html.erb new file mode 100644 index 0000000..dc55f64 --- /dev/null +++ b/app/views/devise/mailer/confirmation_instructions.html.erb @@ -0,0 +1,5 @@ +<p>Welcome <%= @email %>!</p> + +<p>You can confirm your account email through the link below:</p> + +<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p> diff --git a/app/views/devise/mailer/email_changed.html.erb b/app/views/devise/mailer/email_changed.html.erb new file mode 100644 index 0000000..32f4ba8 --- /dev/null +++ b/app/views/devise/mailer/email_changed.html.erb @@ -0,0 +1,7 @@ +<p>Hello <%= @email %>!</p> + +<% if @resource.try(:unconfirmed_email?) %> + <p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p> +<% else %> + <p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p> +<% end %> diff --git a/app/views/devise/mailer/password_change.html.erb b/app/views/devise/mailer/password_change.html.erb new file mode 100644 index 0000000..b41daf4 --- /dev/null +++ b/app/views/devise/mailer/password_change.html.erb @@ -0,0 +1,3 @@ +<p>Hello <%= @resource.email %>!</p> + +<p>We're contacting you to notify you that your password has been changed.</p> diff --git a/app/views/devise/mailer/reset_password_instructions.html.erb b/app/views/devise/mailer/reset_password_instructions.html.erb new file mode 100644 index 0000000..f667dc1 --- /dev/null +++ b/app/views/devise/mailer/reset_password_instructions.html.erb @@ -0,0 +1,8 @@ +<p>Hello <%= @resource.email %>!</p> + +<p>Someone has requested a link to change your password. You can do this through the link below.</p> + +<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p> + +<p>If you didn't request this, please ignore this email.</p> +<p>Your password won't change until you access the link above and create a new one.</p> diff --git a/app/views/devise/mailer/unlock_instructions.html.erb b/app/views/devise/mailer/unlock_instructions.html.erb new file mode 100644 index 0000000..41e148b --- /dev/null +++ b/app/views/devise/mailer/unlock_instructions.html.erb @@ -0,0 +1,7 @@ +<p>Hello <%= @resource.email %>!</p> + +<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p> + +<p>Click the link below to unlock your account:</p> + +<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p> diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb new file mode 100644 index 0000000..5fbb9ff --- /dev/null +++ b/app/views/devise/passwords/edit.html.erb @@ -0,0 +1,25 @@ +<h2>Change your password</h2> + +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + <%= f.hidden_field :reset_password_token %> + + <div class="field"> + <%= f.label :password, "New password" %><br /> + <% if @minimum_password_length %> + <em>(<%= @minimum_password_length %> characters minimum)</em><br /> + <% end %> + <%= f.password_field :password, autofocus: true, autocomplete: "new-password" %> + </div> + + <div class="field"> + <%= f.label :password_confirmation, "Confirm new password" %><br /> + <%= f.password_field :password_confirmation, autocomplete: "new-password" %> + </div> + + <div class="actions"> + <%= f.submit "Change my password" %> + </div> +<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb new file mode 100644 index 0000000..9b486b8 --- /dev/null +++ b/app/views/devise/passwords/new.html.erb @@ -0,0 +1,16 @@ +<h2>Forgot your password?</h2> + +<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + + <div class="field"> + <%= f.label :email %><br /> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + </div> + + <div class="actions"> + <%= f.submit "Send me reset password instructions" %> + </div> +<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb new file mode 100644 index 0000000..38d95b8 --- /dev/null +++ b/app/views/devise/registrations/edit.html.erb @@ -0,0 +1,43 @@ +<h2>Edit <%= resource_name.to_s.humanize %></h2> + +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + + <div class="field"> + <%= f.label :email %><br /> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + </div> + + <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %> + <div>Currently waiting confirmation for: <%= resource.unconfirmed_email %></div> + <% end %> + + <div class="field"> + <%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br /> + <%= f.password_field :password, autocomplete: "new-password" %> + <% if @minimum_password_length %> + <br /> + <em><%= @minimum_password_length %> characters minimum</em> + <% end %> + </div> + + <div class="field"> + <%= f.label :password_confirmation %><br /> + <%= f.password_field :password_confirmation, autocomplete: "new-password" %> + </div> + + <div class="field"> + <%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br /> + <%= f.password_field :current_password, autocomplete: "current-password" %> + </div> + + <div class="actions"> + <%= f.submit "Update" %> + </div> +<% end %> + +<h3>Cancel my account</h3> + +<p>Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %></p> + +<%= link_to "Back", :back %> diff --git a/app/views/devise/registrations/new.html.erb b/app/views/devise/registrations/new.html.erb new file mode 100644 index 0000000..2b6f4a7 --- /dev/null +++ b/app/views/devise/registrations/new.html.erb @@ -0,0 +1,29 @@ +<h2>Register</h2> + +<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + + <div class="field"> + <%= f.label :email %><br /> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + </div> + + <div class="field"> + <%= f.label :password %> + <% if @minimum_password_length %> + <em>(<%= @minimum_password_length %> characters minimum)</em> + <% end %><br /> + <%= f.password_field :password, autocomplete: "new-password" %> + </div> + + <div class="field"> + <%= f.label :password_confirmation %><br /> + <%= f.password_field :password_confirmation, autocomplete: "new-password" %> + </div> + + <div class="actions"> + <%= f.submit "Register" %> + </div> +<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb new file mode 100644 index 0000000..5ede964 --- /dev/null +++ b/app/views/devise/sessions/new.html.erb @@ -0,0 +1,26 @@ +<h2>Log in</h2> + +<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %> + <div class="field"> + <%= f.label :email %><br /> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + </div> + + <div class="field"> + <%= f.label :password %><br /> + <%= f.password_field :password, autocomplete: "current-password" %> + </div> + + <% if devise_mapping.rememberable? %> + <div class="field"> + <%= f.check_box :remember_me %> + <%= f.label :remember_me %> + </div> + <% end %> + + <div class="actions"> + <%= f.submit "Log in" %> + </div> +<% end %> + +<%= render "devise/shared/links" %> diff --git a/app/views/devise/shared/_error_messages.html.erb b/app/views/devise/shared/_error_messages.html.erb new file mode 100644 index 0000000..ba7ab88 --- /dev/null +++ b/app/views/devise/shared/_error_messages.html.erb @@ -0,0 +1,15 @@ +<% if resource.errors.any? %> + <div id="error_explanation"> + <h2> + <%= I18n.t("errors.messages.not_saved", + count: resource.errors.count, + resource: resource.class.model_name.human.downcase) + %> + </h2> + <ul> + <% resource.errors.full_messages.each do |message| %> + <li><%= message %></li> + <% end %> + </ul> + </div> +<% end %> diff --git a/app/views/devise/shared/_links.html.erb b/app/views/devise/shared/_links.html.erb new file mode 100644 index 0000000..b87eaef --- /dev/null +++ b/app/views/devise/shared/_links.html.erb @@ -0,0 +1,25 @@ +<%- if controller_name != 'sessions' %> + <%= link_to "Log in", new_session_path(resource_name) %><br /> +<% end %> + +<%#- if devise_mapping.registerable? && controller_name != 'registrations' %> +<!-- <%#= link_to "Register", new_registration_path(resource_name) %><br />--> +<%# end %> + +<%#- if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations' %> +<!-- <%#= link_to "Forgot your password?", new_password_path(resource_name) %><br />--> +<%# end %> + +<%#- if devise_mapping.confirmable? && controller_name != 'confirmations' %> +<!-- <%#= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br />--> +<%# end %> + +<%#- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> +<!-- <%#= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %><br />--> +<%# end %> + +<%- if devise_mapping.omniauthable? %> + <%- resource_class.omniauth_providers.each do |provider| %> + <%= link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider) %><br /> + <% end %> +<% end %> diff --git a/app/views/devise/unlocks/new.html.erb b/app/views/devise/unlocks/new.html.erb new file mode 100644 index 0000000..ffc34de --- /dev/null +++ b/app/views/devise/unlocks/new.html.erb @@ -0,0 +1,16 @@ +<h2>Resend unlock instructions</h2> + +<%= form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f| %> + <%= render "devise/shared/error_messages", resource: resource %> + + <div class="field"> + <%= f.label :email %><br /> + <%= f.email_field :email, autofocus: true, autocomplete: "email" %> + </div> + + <div class="actions"> + <%= f.submit "Resend unlock instructions" %> + </div> +<% end %> + +<%= render "devise/shared/links" %> diff --git a/config/locales/devise.en.yml b/config/locales/devise.en.yml index ab1f070..8fc2e77 100644 --- a/config/locales/devise.en.yml +++ b/config/locales/devise.en.yml @@ -7,14 +7,14 @@ en: send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes." send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes." failure: - already_authenticated: "You are already signed in." + already_authenticated: "You are already logged in." inactive: "Your account is not activated yet." invalid: "Invalid %{authentication_keys} or password." locked: "Your account is locked." last_attempt: "You have one more attempt before your account is locked." not_found_in_database: "Invalid %{authentication_keys} or password." - timeout: "Your session expired. Please sign in again to continue." - unauthenticated: "You need to sign in or sign up before continuing." + timeout: "Your session expired. Please log in again to continue." + unauthenticated: "You need to log in or register before continuing." unconfirmed: "You have to confirm your email address before continuing." mailer: confirmation_instructions: @@ -34,28 +34,28 @@ en: no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided." send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes." send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes." - updated: "Your password has been changed successfully. You are now signed in." + updated: "Your password has been changed successfully. You are now logged in." updated_not_active: "Your password has been changed successfully." registrations: destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon." - signed_up: "Welcome! You have signed up successfully." - signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated." - signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked." + signed_up: "Welcome! You have registered successfully." + signed_up_but_inactive: "You have registered successfully. However, we could not log you in because your account is not yet activated." + signed_up_but_locked: "You have registered successfully. However, we could not log you in because your account is locked." signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account." update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirmation link to confirm your new email address." updated: "Your account has been updated successfully." - updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to sign in again" + updated_but_not_signed_in: "Your account has been updated successfully, but since your password was changed, you need to log in again" sessions: - signed_in: "Signed in successfully." - signed_out: "Signed out successfully." - already_signed_out: "Signed out successfully." + signed_in: "Logged in successfully." + signed_out: "Logged out successfully." + already_signed_out: "Logged out successfully." unlocks: send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes." send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes." - unlocked: "Your account has been unlocked successfully. Please sign in to continue." + unlocked: "Your account has been unlocked successfully. Please log in to continue." errors: messages: - already_confirmed: "was already confirmed, please try signing in" + already_confirmed: "was already confirmed, please try logging in" confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one" expired: "has expired, please request a new one" not_found: "not found" diff --git a/config/routes.rb b/config/routes.rb index 5f90ff3..6754031 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,5 +4,10 @@ Rails.application.routes.draw do get "logout", to: "devise/sessions#destroy" end devise_for :users, skip: [:registrations] + as :user do + get "users/edit", to: "devise/registrations#edit", as: "edit_user_registration" + put "users", to: "devise/registrations#update", as: "user_registration" + end + root to: "home#index", as: :home_index end |