Update authentication method
This commit is contained in:
17
lib/adamantium/middleware/authenticate.rb
Normal file
17
lib/adamantium/middleware/authenticate.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module Adamantium
|
||||
module Middleware
|
||||
class Authenticate
|
||||
def initialize(app, auth_proc)
|
||||
@app = app
|
||||
@auth_proc = auth_proc
|
||||
end
|
||||
|
||||
def call(env)
|
||||
session = env["rack.session"]
|
||||
return [403, {'Content-Type' => 'text/html'}, ["Unauthorized | <a href=\"/admin/login\">Login</>"]] unless @auth_proc.call(session[:user_id])
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@@ -1,14 +0,0 @@
|
||||
module Adamantium
|
||||
module Middleware
|
||||
class ProcessParams
|
||||
def initialize(app)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
# NOOP for now.
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user