我正在学习本教程https://medium.com/@acesubido/adding-by-factor-authentication-in-activeadmin-2ed134b60042
为了设置2FA,在这种情况下,我需要为用户设置Trailblazer
。在本教程中,它解释了如何为ActiveAdmin添加2FA。
我有以下宝石:
gem 'devise-two-factor' # 2FA auth gem 'rqrcode' # Generates a QR code gem 'trailblazer', '~> 2.1', '>= 2.1.2' gem "trailblazer-rails"
我已经有了操作和合同文件夹。它们看起来像这样:
app/concepts/user/contracts/setup_two_factor.rb
app/concepts/user/operation/setup_two_factor.rb
这是我的operation
的样子:
module User::Operation class SetupTwoFactor < Trailblazer::Operation step Model(User, :find) step Contract::build(constant: User::Contracts::SetupTwoFactor) step Contract::Validate(key: :user) step Contract::Persist(method: :sync) success :set_otp_secret! step Contract::Persist(method: :save) def set_otp_secret!(options, params:, **) if options['model'].otp_required_for_login unless options['model'].otp_secret.present? options['model'].otp_secret = User.generate_otp_secret end end end end end
这就是我的contracts
的样子:
module User::Contract class SetupTwoFactor < Reform::Form property :otp_required_for_login end end
问题
My 问题 comes that, whenever I want to click on the save
button. (Image Below)
I get this 问题:
I've check the documentation and everything but can't seem to find the 问题.