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