Sha256: bcbed6649cdaa90b8c82c96a44eb0f1fb5cac6aacf0b419314363f2d3eff3243

Contents?: true

Size: 530 Bytes

Versions: 2

Compression:

Stored size: 530 Bytes

Contents

Trestle.configure do |config|

  config.hook('auth.login.form') do
    render 'trestle/auth/otp'
  end

  config.auth.authenticate = ->(params) {

    scope = Trestle.config.auth.user_scope

    user = scope.authenticate(params[Trestle.config.auth.authenticate_with], params[:password])

    if user && user.otp_module?
      if params[:otp_code_token].present? && user.authenticate_otp(params[:otp_code_token], drift: 60)
        return user
      else
        return false
      end
    else
      return user
    end

  }

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trestle-auth-otp-0.2.0 config/initializers/trestle.rb
trestle-auth-otp-0.1.1 config/initializers/trestle.rb