Disabled params wrapping.
This commit is contained in:
parent
af22e22fb2
commit
7e3b63a7ba
8 changed files with 13 additions and 12 deletions
|
@ -59,9 +59,8 @@ class CalendarSubscriptions extends App.ControllerSubContent
|
|||
store: ->
|
||||
# get data
|
||||
data =
|
||||
user:
|
||||
calendar_subscriptions:
|
||||
tickets: @preferences
|
||||
calendar_subscriptions:
|
||||
tickets: @preferences
|
||||
|
||||
@ajax(
|
||||
id: 'preferences'
|
||||
|
|
|
@ -41,7 +41,7 @@ class Index extends App.ControllerSubContent
|
|||
id: 'preferences'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/users/preferences"
|
||||
data: JSON.stringify({user:params})
|
||||
data: JSON.stringify(params)
|
||||
processData: true
|
||||
success: @success
|
||||
error: @error
|
||||
|
|
|
@ -156,7 +156,7 @@ class Index extends App.ControllerSubContent
|
|||
id: 'preferences'
|
||||
type: 'PUT'
|
||||
url: @apiPath + '/users/preferences'
|
||||
data: JSON.stringify({user:params})
|
||||
data: JSON.stringify(params)
|
||||
processData: true
|
||||
success: @success
|
||||
error: @error
|
||||
|
|
|
@ -219,7 +219,7 @@ class App.CustomerChat extends App.Controller
|
|||
id: 'preferences'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/users/preferences"
|
||||
data: JSON.stringify(user: {chat: preferences.chat})
|
||||
data: JSON.stringify(chat: preferences.chat)
|
||||
processData: true
|
||||
success: @success
|
||||
error: @error
|
||||
|
@ -757,7 +757,7 @@ class Setting extends App.ControllerModal
|
|||
id: 'preferences'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/users/preferences"
|
||||
data: JSON.stringify({user:params})
|
||||
data: JSON.stringify(params)
|
||||
processData: true
|
||||
success: @success
|
||||
error: @error
|
||||
|
|
|
@ -12,7 +12,7 @@ class Index extends App.Controller
|
|||
id: 'preferences'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/users/preferences"
|
||||
data: JSON.stringify({user:{intro:true}})
|
||||
data: JSON.stringify(intro: true)
|
||||
processData: true
|
||||
)
|
||||
@navigate '#'
|
||||
|
|
|
@ -231,7 +231,7 @@ class App.CTI extends App.Controller
|
|||
id: 'preferences'
|
||||
type: 'PUT'
|
||||
url: "#{@apiPath}/users/preferences"
|
||||
data: JSON.stringify(user: {cti: state})
|
||||
data: JSON.stringify(cti: state)
|
||||
processData: true
|
||||
)
|
||||
|
||||
|
|
|
@ -803,10 +803,12 @@ curl http://localhost/api/v1/users/preferences -v -u #{login}:#{password} -H "Co
|
|||
def preferences
|
||||
raise Exceptions::UnprocessableEntity, 'No current user!' if !current_user
|
||||
|
||||
if params[:user]
|
||||
preferences_params = params.except(:controller, :action)
|
||||
|
||||
if preferences_params.present?
|
||||
user = User.find(current_user.id)
|
||||
user.with_lock do
|
||||
params[:user].permit!.to_h.each do |key, value|
|
||||
preferences_params.permit!.to_h.each do |key, value|
|
||||
user.preferences[key.to_sym] = value
|
||||
end
|
||||
user.save!
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
||||
ActiveSupport.on_load(:action_controller) do
|
||||
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
||||
wrap_parameters format: [] if respond_to?(:wrap_parameters)
|
||||
end
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
|
|
Loading…
Reference in a new issue