加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 无效盐(BCrypt :: Errors :: InvalidSalt)

发布时间:2020-12-17 01:34:21 所属栏目:百科 来源:网络整理
导读:自从升级到 Ruby 2.2.0后,我在测试中收到以下消息: invalid salt (BCrypt::Errors::InvalidSalt) 我没有找到任何升级通知来帮助我理解这个问题.我正在使用Rails 4.1.8和Sorcery 0.8.6. 还有其他人有这个问题吗? 更多细节: 我正在使用法术,而不是设计.加密
自从升级到 Ruby 2.2.0后,我在测试中收到以下消息:

invalid salt (BCrypt::Errors::InvalidSalt)

我没有找到任何升级通知来帮助我理解这个问题.我正在使用Rails 4.1.8和Sorcery 0.8.6.

还有其他人有这个问题吗?

更多细节:

我正在使用法术,而不是设计.加密数据是密码.
这一切都始于Cucumber测试,有两种情况:
我曾经将@user发送到邮件程序以准备邮件的数据.这是代码:

UserMailer.passphrase_reset_notification(@user).deliver

哪个用我在初始消息中写的消息生成了异常.作为一种解决方法而不是发送@user我发送了我需要的字段并且它有效.这是新代码:

UserMailer.passphrase_reset_notification(@ user.name,@ user.email).deliver

但第二种情况是注册.它在开发中失败了,我不得不添加:salt到user_params来修复它.但它并没有解决测试环境中的问题.

没有堆栈跟踪,只有一条衬线消息与我的方案行导致错误.

我按下“注册”
??????无效盐(BCrypt :: Errors :: InvalidSalt)
??????./app/controllers/users_controller.rb:66:in block in create’
??????./app/controllers/users_controller.rb:64:increate”
??????./app/controllers/application_controller.rb:120:in scope_current_tenant’
??????./features/step_definitions/web_steps.rb:53:in/^(?:|I)按“([^”] *)“$/”
??????features / users / sign_up.feature:149:in`我按“注册”

我删除了用户表中字段“salt”的“null:false”,正如社区成员在一个或多或少类似问题的帖子中所建议的那样,它也没有帮助.

我的主要问题仍然是:Ruby新版本(2.2.0)与此有什么关系?如果我升级产品,可能会有什么惊喜呢?

解决方法

我刚修好了.原来它与使用has_secure_password(使用bcrypt-ruby)序列化对象有关

更具体地说,像下面这样的东西引起了Sidekiq的问题,因为它试图将参数序列化为Redis排队的对象.

@user = User.new(
  :firstname => 'Scott',:lastname => 'Klein',:password => 'mypass',:password_confirmation => 'mypass'   
)
@user.save!

# broken
# note that @user.password can still be called here
# and sidekiq will attempt to serialize this whole object using YAML
# and this is the serialization issue that barfs (in the depths of YAML)
UserMailer.delay.new_user_signup(@user)

# fixed
# i just passed the id and then recalled the user record in the mailer class
UserMailer.delay.new_user_signup(@user.id)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读