From 185057396184ffa3be0491a6ddd38a2f7414a79e Mon Sep 17 00:00:00 2001 From: Alex Ling Date: Sun, 16 Feb 2020 00:12:03 +0000 Subject: [PATCH] - use `request_path_startswith` instead of the `exclude` macro in AuthHandler --- src/auth_handler.cr | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/auth_handler.cr b/src/auth_handler.cr index 8203aea..d6c8887 100644 --- a/src/auth_handler.cr +++ b/src/auth_handler.cr @@ -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