mirror of
https://github.com/hkalexling/Mango.git
synced 2026-04-04 00:00:51 -04:00
- implement login and load images from zip
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
require "kemal"
|
||||
require "./storage"
|
||||
|
||||
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)
|
||||
my_cookie = HTTP::Cookie.new(
|
||||
name: "Example",
|
||||
value: "KemalCR"
|
||||
)
|
||||
env.response.cookies << my_cookie
|
||||
|
||||
pp env.request.cookies
|
||||
env.request.cookies.each do |c|
|
||||
next if c.name != "token"
|
||||
if @storage.verify_token c.value
|
||||
return call_next env
|
||||
end
|
||||
end
|
||||
|
||||
env.redirect "/login"
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user