ruby-on-rails – 无效盐(BCrypt :: Errors :: InvalidSalt)
自从升级到
Ruby 2.2.0后,我在测试中收到以下消息:
invalid salt (BCrypt::Errors::InvalidSalt) 我没有找到任何升级通知来帮助我理解这个问题.我正在使用Rails 4.1.8和Sorcery 0.8.6. 还有其他人有这个问题吗? 更多细节: 我正在使用法术,而不是设计.加密数据是密码. UserMailer.passphrase_reset_notification(@user).deliver 哪个用我在初始消息中写的消息生成了异常.作为一种解决方法而不是发送@user我发送了我需要的字段并且它有效.这是新代码: UserMailer.passphrase_reset_notification(@ user.name,@ user.email).deliver 但第二种情况是注册.它在开发中失败了,我不得不添加:salt到user_params来修复它.但它并没有解决测试环境中的问题. 没有堆栈跟踪,只有一条衬线消息与我的方案行导致错误. 我按下“注册” 我删除了用户表中字段“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) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |