Fix empty profile check
This commit is contained in:
parent
076e4ca4fb
commit
a505b23bb1
@ -4,7 +4,11 @@ module Dayoff
|
||||
end
|
||||
|
||||
def profile?(profile_id : ProfileId) : Bool
|
||||
Dir.exists? File.join(@base_path, profile_id.to_s)
|
||||
if profile_id.empty?
|
||||
false
|
||||
else
|
||||
Dir.exists? File.join(@base_path, profile_id.to_s)
|
||||
end
|
||||
end
|
||||
|
||||
def profile(profile_id : ProfileId) : Profile
|
||||
|
@ -3,6 +3,10 @@ module Dayoff
|
||||
def initialize(@id : String)
|
||||
end
|
||||
|
||||
def empty? : Bool
|
||||
@id.empty?
|
||||
end
|
||||
|
||||
def to_s : String
|
||||
@id
|
||||
end
|
||||
|
@ -7,7 +7,6 @@ class CheckProfileHandler < Kemal::Handler
|
||||
|
||||
def call(env)
|
||||
path = env.request.path
|
||||
puts "run check profile"
|
||||
if /^\/api/.match(path)
|
||||
profile_id = get_profile_id env
|
||||
if @app.profile? profile_id
|
||||
@ -26,7 +25,6 @@ class CheckProfileHandler < Kemal::Handler
|
||||
private def get_profile_id(env) : Dayoff::ProfileId
|
||||
profile_id = env.params.query[QUERY_PARAM]? ||
|
||||
env.request.headers[HEADER_PARAM]? || ""
|
||||
puts "PROFILE_ID", profile_id
|
||||
Dayoff::ProfileId.new profile_id
|
||||
Dayoff::ProfileId.new profile_id.strip
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user