Fix user renames and deletions

related to #1941
This commit is contained in:
Toks
2014-05-30 02:57:23 -04:00
parent c7cecc1216
commit f132e42a12
2 changed files with 1 additions and 2 deletions

View File

@@ -50,7 +50,7 @@ class UsersController < ApplicationController
@user = User.find(params[:id])
check_privilege(@user)
sanitize_params!
@user.update_attributes(params[:user], :as => CurrentUser.role)
@user.update_attributes(params[:user].except(:name), :as => CurrentUser.role)
cookies.delete(:favorite_tags)
cookies.delete(:favorite_tags_with_categories)
if @user.errors.any?

View File

@@ -19,7 +19,6 @@ class User < ActiveRecord::Base
attr_accessor :password, :old_password
attr_accessible :enable_privacy_mode, :enable_post_navigation, :new_post_navigation_layout, :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr, :time_zone, :default_image_size, :enable_sequential_post_navigation, :per_page, :hide_deleted_posts, :style_usernames, :enable_auto_complete, :custom_style, :show_deleted_children, :as => [:moderator, :janitor, :contributor, :gold, :member, :anonymous, :default, :builder, :admin]
attr_accessible :level, :as => :admin
attr_readonly :name
validates_length_of :name, :within => 2..100, :on => :create
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
validates_format_of :name, :with => /\A[^_].*[^_]\Z/, :on => :create, :message => "cannot begin or end with an underscore"