Guest User

Untitled

a guest
Feb 19th, 2018
284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.12 KB | None | 0 0
  1. Started POST "/auth" for 127.0.0.1
  2. Processing by DeviseTokenAuth::RegistrationsController#create as */*
  3. Parameters: {"email"=>"aa@test.com", "password"=>"[FILTERED]", "fname"=>"test", "lname"=>"test", "user_id"=>"1", "id"=>"1"}
  4.  
  5. Unpermitted parameters: :fname, :lname, :user_id, :id
  6. Unpermitted parameters: :fname, :lname, :user_id, :id
  7. Unpermitted parameters: :fname, :lname, :user_id, :id
  8.  
  9. class Users::RegistrationsController < Devise::RegistrationsController
  10. before_action :configure_sign_up_params, only: [:create]
  11. # before_action :configure_account_update_params, only: [:update]
  12.  
  13. # GET /resource/sign_up
  14. def new
  15. build_resource({})
  16. self.resource.customers.build
  17. self.resource.sellers.build
  18. respond_with self.resource
  19. end
  20.  
  21. # POST /resource
  22. def create
  23. build_resource(sign_up_params)
  24.  
  25. if resource.user_type == 'Customer'
  26. resource.user = Customer.new
  27. else
  28. resource.user = Seller.new
  29. end
  30.  
  31. resource_saved = resource.save
  32. yield resource if block_given?
  33. if resource_saved
  34. if resource.active_for_authentication?
  35. set_flash_message :notice, :signed_up if is_flashing_format?
  36. sign_up(resource_name, resource)
  37. respond_with resource, location: after_sign_up_path_for(resource)
  38. else
  39. set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
  40. expire_data_after_sign_in!
  41. respond_with resource, location: after_inactive_sign_up_path_for(resource)
  42. end
  43. else
  44. clean_up_passwords resource
  45. @validatable = devise_mapping.validatable?
  46. if @validatable
  47. @minimum_password_length = resource_class.password_length.min
  48. end
  49. respond_with resource
  50. end
  51. end
  52.  
  53. # GET /resource/edit
  54. # def edit
  55. # super
  56. # end
  57.  
  58. # PUT /resource
  59. # def update
  60. # super
  61. # end
  62.  
  63. # DELETE /resource
  64. # def destroy
  65. # super
  66. # end
  67.  
  68. # GET /resource/cancel
  69. # Forces the session data which is usually expired after sign
  70. # in to be expired now. This is useful if the user wants to
  71. # cancel oauth signing in/up in the middle of the process,
  72. # removing all OAuth session data.
  73. # def cancel
  74. # super
  75. # end
  76.  
  77. protected
  78.  
  79. # If you have extra params to permit, append them to the sanitizer.
  80. def configure_sign_up_params
  81. devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
  82. end
  83.  
  84. # If you have extra params to permit, append them to the sanitizer.
  85. # def configure_account_update_params
  86. # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
  87. # end
  88.  
  89. # The path used after sign up.
  90. # def after_sign_up_path_for(resource)
  91. # super(resource)
  92. # end
  93.  
  94. # The path used after sign up for inactive accounts.
  95. # def after_inactive_sign_up_path_for(resource)
  96. # super(resource)
  97. # end
  98.  
  99. private
  100.  
  101. def sign_up_params
  102. params.require(:user).permit(:user_id, customer: [:fname, :lname], seller: [:fname, :lname])
  103. end
  104.  
  105. end
  106.  
  107. before_action :configure_permitted_parameters, if: :devise_controller?
  108.  
  109. protected
  110.  
  111. def configure_permitted_parameters
  112. devise_parameter_sanitizer.permit(:sign_up, keys: shipper_attributes: {fname})
  113. end
Add Comment
Please, Sign In to add comment