Sha256: d38e7fe32669c7802ce9e479d2bfa5de6934515d8371648e7f8ff976defe3915

Contents?: true

Size: 561 Bytes

Versions: 2

Compression:

Stored size: 561 Bytes

Contents

Trestle.configure do |config|

  config.hook('auth.login.form') do |f|
    render partial: 'trestle/auth/otp', locals: { f: f }
  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.2 config/initializers/trestle.rb
trestle-auth-otp-0.2.1 config/initializers/trestle.rb