warden.authenticate!(auth_options)
为这些参数工作正常:
{ “UTF8”=> “中✓”, “authenticity_token”=> “中5BMAUoZLUEgPZBVOAcQ8lFD4 + pumP9kEvvXyelbnjeO36AZJQt2oRlraicQ6quvh / dccS0ELUkxjACgFcWFYAg ==”, “user”=> {“email”=>“vijay@xyz.com”,“password”=>“xyz”, “phone”=>“9443429932”},“action”=>“创建”,“控制器”=>“会话”, “format”=>“json”,“session”=> {“user”=> {“email”=>“vijay@xyz.com”, “password”=>“xyz”,“phone”=>“9443429932”}}}
但未能做到这些:
{ “UTF8”=> “中✓”, “authenticity_token”=> “中/ ly2phwfsD3HEVkHK39ajYQGv6R4uj2z3B + 3eiZEU0qtp7C92IlIM5KvxY0QEY34KSlZdJ + OtvsB6m0FAcKGqw ==”, “user”=> {“phone”=>“9443429932”,“password”=>“xyz”, “email”=>“vijay@xyz.com”},“action”=>“创建”, “controller”=>“sessions”,“format”=>“json”, “session”=> {“user”=> {“phone”=>“9443429932”,“password”=>“xyz”, “电子邮件”=> “中vijay@xyz.com”}}}
除订单外,两种情况下的数据相同。 长期坚持这一点。
这是日志:
在2017-04-10为127.0.0.1开始POST“/users/sign_in.json” 10:53:07 +0530由SessionsController处理#create as JSON
参数:{“utf8”=>“✓”, “authenticity_token”=> “中XVMbYLTgv4eFbv9pX5lJD3U6DHF17o18rVIjqQLo4skOqB17cHZHidDQY + Nk95562BXqoZLaBjRwp / nWJW43KA ==”, “user”=> {“phone”=>“9443429932”,“password”=>“[FILTERED]”}, “会话”=> { “用户”=> { “电话”=> “中9443429932”, “password”=>“[FILTERED]”}}}用户加载(0.3ms)SELECTusers
。* FROMusers
WHEREusers
。id
= 12422916 AND(invitation_token为null) LIMIT 1在15ms完成401未授权
答案 0 :(得分:3)
发现了这个问题。 warden正在从request.params读取params 我编辑了参数,但它没有反映在request.params。
request.params [:用户] .merge(PARAMS [:用户])! 这解决了这个问题。