From 1abdcb3cf36301fb8ef8df5c1040e2467caeb873 Mon Sep 17 00:00:00 2001 From: r888888888 Date: Tue, 30 Jun 2015 13:13:57 -0700 Subject: [PATCH] fixes #2419 --- .../maintenance/user/passwords_controller.rb | 9 ++++++++ app/controllers/users_controller.rb | 2 ++ .../maintenance/user/passwords/edit.html.erb | 15 +++++++++++++ app/views/users/edit.html.erb | 21 ++++++++++--------- config/routes.rb | 2 ++ script/fixes/034_fix_dmail_filters.rb | 15 +++++++++++++ 6 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 app/controllers/maintenance/user/passwords_controller.rb create mode 100644 app/views/maintenance/user/passwords/edit.html.erb create mode 100644 script/fixes/034_fix_dmail_filters.rb diff --git a/app/controllers/maintenance/user/passwords_controller.rb b/app/controllers/maintenance/user/passwords_controller.rb new file mode 100644 index 000000000..c14592059 --- /dev/null +++ b/app/controllers/maintenance/user/passwords_controller.rb @@ -0,0 +1,9 @@ +module Maintenance + module User + class PasswordsController < ApplicationController + def edit + @user = CurrentUser.user + end + end + end +end diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 3049a56bc..e745e9e89 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -55,6 +55,8 @@ class UsersController < ApplicationController cookies.delete(:favorite_tags_with_categories) if @user.errors.any? flash[:notice] = @user.errors.full_messages.join("; ") + else + flash[:notice] = "Settings updated" end respond_with(@user) end diff --git a/app/views/maintenance/user/passwords/edit.html.erb b/app/views/maintenance/user/passwords/edit.html.erb new file mode 100644 index 000000000..e259ae8de --- /dev/null +++ b/app/views/maintenance/user/passwords/edit.html.erb @@ -0,0 +1,15 @@ +
+
+

Change Password

+ + <%= simple_form_for @user do |f| %> + <%= f.input :old_password, :as => :password, :input_html => {:autocomplete => "off"} %> + <%= f.input :password, :label => "New password", :input_html => {:autocomplete => "off"} %> + <%= f.button :submit, "Submit" %> + <% end %> +
+
+ +<% content_for(:page_title) do %> + Change Password - <%= Danbooru.config.app_name %> +<% end %> diff --git a/app/views/users/edit.html.erb b/app/views/users/edit.html.erb index 729b573b4..c439a40d1 100644 --- a/app/views/users/edit.html.erb +++ b/app/views/users/edit.html.erb @@ -3,7 +3,14 @@

Settings

<%= simple_form_for @user do |f| %> -

<%= link_to "Basic settings", "#basic-settings", :class => "active" %> | <%= link_to "Advanced settings", "#advanced-settings" %> | <%= link_to "Change password", "#change-password" %> | <%= link_to "Delete account", maintenance_user_deletion_path, :id => "delete-account" %>

+

+ <%= link_to "Basic settings", "#basic-settings", :class => "active" %> + | <%= link_to "Advanced settings", "#advanced-settings" %> + <% if CurrentUser.user.id == @user.id %> + | <%= link_to "Change password", edit_user_password_path(:user_id => @user.id), :id => "change-password" %> + | <%= link_to "Delete account", maintenance_user_deletion_path, :id => "delete-account" %> + <% end %> +

@@ -77,12 +84,6 @@ <%= f.input :custom_style, :label => "Custom CSS style".html_safe, :hint => "Style to apply to the whole site.", :input_html => {:size => "40x5"} %>
-
- <%= f.input :password, :hint => "Leave blank if you don't want to change your password", :label => "New password", :input_html => {:autocomplete => "off"} %> - - <%= f.input :old_password, :as => :password, :input_html => {:autocomplete => "off"} %> -
- <%= f.button :submit, "Submit" %> <% end %> @@ -95,11 +96,11 @@ <% content_for(:html_header) do %>