Class: Clerk::Rack::Reverification
- Inherits:
-
Object
- Object
- Clerk::Rack::Reverification
- Defined in:
- lib/clerk/rack_middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, routes: ["/*"], preset: Clerk::StepUp::Preset::STRICT) ⇒ Reverification
constructor
A new instance of Reverification.
Constructor Details
#initialize(app, routes: ["/*"], preset: Clerk::StepUp::Preset::STRICT) ⇒ Reverification
Returns a new instance of Reverification.
90 91 92 93 94 95 |
# File 'lib/clerk/rack_middleware.rb', line 90 def initialize(app, routes: ["/*"], preset: Clerk::StepUp::Preset::STRICT) @app = app @preset = preset @included_routes, @included_routes_wildcards = Clerk::Utils.filter_routes(routes) end |
Instance Method Details
#call(env) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/clerk/rack_middleware.rb', line 97 def call(env) raise Clerk::ConfigurationError, "`Clerk::Rack::Reverification` must be initialized after `Clerk::Rack::Middleware`" unless env["clerk.initialized"] return @app.call(env) if env["clerk.excluded_route"] req = ::Rack::Request.new(env) valid_route = @included_routes[req.path] || @included_routes_wildcards.any? { |route| req.path.start_with?(route) } if valid_route && env["clerk"].user_needs_reverification?(@preset) return env["clerk"].user_reverification_rack_response(@preset) end @app.call(env) end |