Include port number in token

This commit is contained in:
Alex Ling
2020-06-01 13:50:51 +00:00
parent 9b5aea223d
commit e214e00dfb
3 changed files with 13 additions and 5 deletions

View File

@@ -9,7 +9,9 @@ class AuthHandler < Kemal::Handler
def call(env)
return call_next(env) if request_path_startswith env, ["/login", "/logout"]
cookie = env.request.cookies.find { |c| c.name == "token" }
cookie = env.request.cookies.find do |c|
c.name == "token-#{Config.current.port}"
end
if cookie.nil? || !@storage.verify_token cookie.value
return redirect env, "/login"
end