- use request_path_startswith instead of the exclude macro in

AuthHandler
This commit is contained in:
Alex Ling 2020-02-16 00:12:03 +00:00
parent e413542c42
commit 1850573961

View File

@ -3,16 +3,14 @@ require "./storage"
require "./util"
class AuthHandler < Kemal::Handler
exclude ["/login"]
exclude ["/login"], "POST"
property storage : Storage
def initialize(@storage)
end
def call(env)
return call_next(env) if exclude_match?(env)
return call_next(env) \
if request_path_startswith env, ["/login", "/logout"]
cookie = env.request.cookies.find { |c| c.name == "token" }
if cookie.nil? || ! @storage.verify_token cookie.value