Fix incorrect login redirect (#64)

This commit is contained in:
Alex Ling 2020-06-09 14:46:45 +00:00
parent a0e5a03052
commit 5cd6f3eacb
3 changed files with 10 additions and 4 deletions

View File

@ -63,7 +63,10 @@ class AuthHandler < Kemal::Handler
end
def handle_auth(env)
return call_next(env) if request_path_startswith env, ["/login", "/logout"]
if request_path_startswith env, ["/login", "/logout"] ||
requesting_static_file env
return call_next(env)
end
unless validate_token env
env.session.string "callback", env.request.path

View File

@ -16,10 +16,8 @@ class FS
end
class StaticHandler < Kemal::Handler
@dirs = ["/css", "/js", "/img", "/favicon.ico"]
def call(env)
if request_path_startswith env, @dirs
if requesting_static_file env
file = FS.get? env.request.path
return call_next env if file.nil?

View File

@ -2,6 +2,11 @@ require "big"
IMGS_PER_PAGE = 5
UPLOAD_URL_PREFIX = "/uploads"
STATIC_DIRS = ["/css", "/js", "/img", "/favicon.ico"]
def requesting_static_file(env)
request_path_startswith env, STATIC_DIRS
end
macro layout(name)
base_url = Config.current.base_url