Use a helper function to set token cookie

This commit is contained in:
Alex Ling
2020-06-05 14:31:12 +00:00
parent 373ff6520a
commit 012fd71ab4
3 changed files with 9 additions and 10 deletions

View File

@@ -43,12 +43,7 @@ class AuthHandler < Kemal::Handler
token = verify_user value
return false if token.nil?
# TODO use port number in token key
cookie = HTTP::Cookie.new "token", token
cookie.path = Config.current.base_url
cookie.expires = Time.local.shift years: 1
env.response.cookies << cookie
set_token_cookie env, token
return true
end
end