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 %>