Class: Rack::ChangePasswordUrl::Middleware
- Inherits:
-
Object
- Object
- Rack::ChangePasswordUrl::Middleware
- Defined in:
- lib/rack/change-password-url/middleware.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app) ⇒ Middleware
constructor
A new instance of Middleware.
Constructor Details
#initialize(app) ⇒ Middleware
Returns a new instance of Middleware.
8 9 10 11 12 13 |
# File 'lib/rack/change-password-url/middleware.rb', line 8 def initialize(app) @app = app @config = Rack::ChangePasswordUrl.configuration @redirect_path = @config.redirect_path end |
Instance Method Details
#call(env) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/rack/change-password-url/middleware.rb', line 15 def call(env) req = Rack::Request.new(env) if req.path == '/.well-known/change-password' unless @redirect_path.nil? return [ 302, { 'Location' => @redirect_path }, [] ] else raise Error.new('Failed to redirect change password url: not set redirect_path') end end @app.call(env) end |