Skip to content

Commit

Permalink
chore: conform to new model interface
Browse files Browse the repository at this point in the history
  • Loading branch information
caspiano committed Apr 28, 2021
1 parent c7a3299 commit c6ef4b7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion shard.lock
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ shards:

placeos-models:
git: https://github.com/placeos/models.git
version: 4.18.0
version: 4.18.1

placeos-resource:
git: https://github.com/place-labs/resource.git
Expand Down
2 changes: 1 addition & 1 deletion spec/helper.cr
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ end
# Yield an authenticated user, and a header with Authorization bearer set
def authentication(scope = ["public"] of String)
test_user_email = "[email protected]"
existing = PlaceOS::Model::User.get_all([test_user_email], index: :email).first?
existing = PlaceOS::Model::User.find_all([test_user_email], index: :email).first?

authenticated_user = if existing
existing
Expand Down
4 changes: 2 additions & 2 deletions src/placeos-rest-api/controllers/systems.cr
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module PlaceOS::Api
# Finds all the systems with the specified email address
get "/with_emails", :find_by_email do
emails = params["in"].split(',').map(&.strip).reject(&.empty?).uniq!
systems = Model::ControlSystem.get_all(emails, index: :email).to_a
systems = Model::ControlSystem.find_all(emails, index: :email).to_a
set_collection_headers(systems.size, Model::ControlSystem.table_name)
render json: systems
end
Expand Down Expand Up @@ -184,7 +184,7 @@ module PlaceOS::Api
documents = if current_control_system.zones.empty?
[] of Model::Zone
else
Model::Zone.get_all(current_control_system.zones).to_a
Model::Zone.find_all(current_control_system.zones).to_a
end

set_collection_headers(documents.size, Model::Zone.table_name)
Expand Down
4 changes: 2 additions & 2 deletions src/placeos-rest-api/utilities/current-user.cr
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module PlaceOS::Api
token_domain_host = URI.parse(user_token.domain).host
authority_domain_host = URI.parse(authority.domain.as(String)).host
unless token_domain_host == authority_domain_host
Log.warn { {message: "authority domain does not match token's", action: "authorize!", token_domain: user_token.aud, authority_domain: authority.domain} }
Log.warn { {message: "authority domain does not match token's", action: "authorize!", token_domain: user_token.domain, authority_domain: authority.domain} }
raise Error::Unauthorized.new "authority domain does not match token's"
end
user_token
Expand All @@ -49,7 +49,7 @@ module PlaceOS::Api
def check_oauth_scope
utoken = user_token
unless utoken.scope.includes?("public")
Log.warn { {message: "unknown scope #{utoken.scope}", action: "authorize!", host: request.hostname, sub: utoken.sub} }
Log.warn { {message: "unknown scope #{utoken.scope}", action: "authorize!", host: request.hostname, id: utoken.id} }
raise Error::Unauthorized.new "public scope required for access"
end
end
Expand Down

0 comments on commit c6ef4b7

Please sign in to comment.