From 7971d7ac77c83717afcceaa1f476d1eb9afd5918 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 2 Jul 2017 15:00:52 -0400 Subject: Styled password reset form --- app/assets/stylesheets/userdata/layout.scss | 21 ++++++++++++++++++--- app/controllers/users/passwords_controller.rb | 1 + app/views/devise/passwords/edit.html.erb | 25 ------------------------- app/views/devise/passwords/new.html.erb | 16 ---------------- app/views/users/passwords/edit.html.haml | 16 ++++++++++++++++ app/views/users/passwords/new.html.haml | 11 +++++++++++ config/routes.rb | 6 +++++- 7 files changed, 51 insertions(+), 45 deletions(-) delete mode 100644 app/views/devise/passwords/edit.html.erb delete mode 100644 app/views/devise/passwords/new.html.erb create mode 100644 app/views/users/passwords/edit.html.haml create mode 100644 app/views/users/passwords/new.html.haml diff --git a/app/assets/stylesheets/userdata/layout.scss b/app/assets/stylesheets/userdata/layout.scss index 9e4906e..6b99d46 100644 --- a/app/assets/stylesheets/userdata/layout.scss +++ b/app/assets/stylesheets/userdata/layout.scss @@ -27,7 +27,7 @@ body { } } - input[type=text], input[type=password] { + input[type=text], input[type=password], input[type=email] { font-size: 24px; padding: 3px; width: 100%; @@ -69,7 +69,7 @@ body { font-size: .75em; } -#flash { +#flash, #error_explanation li { color: black; background-color: white; padding: .75em; @@ -80,7 +80,7 @@ body { box-shadow: 1px 1px 5px 0px rgba(0,0,0,0.75); } -.flash-alert { +.flash-alert, #error_explanation li { border-left: 5px solid red; } @@ -91,3 +91,18 @@ body { .flash-tag { font-weight: bold; } + +#error_explanation { + h2 { + display: none; + } + + ul { + margin-top: 0; + padding: 0; + } + + li { + list-style-type: none; + } +} diff --git a/app/controllers/users/passwords_controller.rb b/app/controllers/users/passwords_controller.rb index 53cc34e..56ef149 100644 --- a/app/controllers/users/passwords_controller.rb +++ b/app/controllers/users/passwords_controller.rb @@ -1,4 +1,5 @@ class Users::PasswordsController < Devise::PasswordsController + layout "userdata" # GET /resource/password/new # def new # super diff --git a/app/views/devise/passwords/edit.html.erb b/app/views/devise/passwords/edit.html.erb deleted file mode 100644 index 6a796b0..0000000 --- a/app/views/devise/passwords/edit.html.erb +++ /dev/null @@ -1,25 +0,0 @@ -

Change your password

- -<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %> - <%= devise_error_messages! %> - <%= f.hidden_field :reset_password_token %> - -
- <%= f.label :password, "New password" %>
- <% if @minimum_password_length %> - (<%= @minimum_password_length %> characters minimum)
- <% end %> - <%= f.password_field :password, autofocus: true, autocomplete: "off" %> -
- -
- <%= f.label :password_confirmation, "Confirm new password" %>
- <%= f.password_field :password_confirmation, autocomplete: "off" %> -
- -
- <%= f.submit "Change my password" %> -
-<% end %> - -<%= render "devise/shared/links" %> diff --git a/app/views/devise/passwords/new.html.erb b/app/views/devise/passwords/new.html.erb deleted file mode 100644 index 3d6d11a..0000000 --- a/app/views/devise/passwords/new.html.erb +++ /dev/null @@ -1,16 +0,0 @@ -

Forgot your password?

- -<%= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %> - <%= devise_error_messages! %> - -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true %> -
- -
- <%= f.submit "Send me reset password instructions" %> -
-<% end %> - -<%= render "devise/shared/links" %> diff --git a/app/views/users/passwords/edit.html.haml b/app/views/users/passwords/edit.html.haml new file mode 100644 index 0000000..3d2d9ee --- /dev/null +++ b/app/views/users/passwords/edit.html.haml @@ -0,0 +1,16 @@ +%h2 Change your password += devise_error_messages! +#principal + = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| + = f.hidden_field :reset_password_token + .field + = f.label :password, "New password" + - if @minimum_password_length + %em= "(#{@minimum_password_length} characters minimum)" + = f.password_field :password, autofocus: true, autocomplete: "off" + .field + = f.label :password_confirmation, "Confirm new password" + = f.password_field :password_confirmation, autocomplete: "off" + .submit-field + = f.submit "Change my password" +.navigation= link_to "← Back to thoughts", root_url diff --git a/app/views/users/passwords/new.html.haml b/app/views/users/passwords/new.html.haml new file mode 100644 index 0000000..03d3854 --- /dev/null +++ b/app/views/users/passwords/new.html.haml @@ -0,0 +1,11 @@ +%h2 Forgot your password? += devise_error_messages! +#principal + = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| + .field + = f.label :email + = f.email_field :email, autofocus: true + .submit-field + = f.submit "Submit" +.navigation= link_to "Log in", new_session_path(resource_name) +.navigation= link_to "← Back to thoughts", root_url diff --git a/config/routes.rb b/config/routes.rb index 449cda1..1003a8b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,7 +6,11 @@ Rails.application.routes.draw do end mount Ckeditor::Engine => '/ckeditor' - devise_for :users, controllers: { sessions: 'users/sessions' } + + devise_for :users, controllers: { + sessions: 'users/sessions', + passwords: 'users/passwords' + } root "records#index" -- cgit 1.4.1