mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-02 10:55:30 -04:00
- use request_path_startswith
instead of the exclude
macro in
AuthHandler
This commit is contained in:
parent
e413542c42
commit
1850573961
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user