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