Skip to content

Commit

Permalink
do not make password required for user input
Browse files Browse the repository at this point in the history
  • Loading branch information
simonfranzen committed Sep 18, 2020
1 parent da54ce2 commit 26b86cc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/graphql/mutations/companies/update_company.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def resolve(id:, attributes:)
# find company
company = ::Companies::Company.accessible_by(current_ability).find_by(id: id)
if company.nil?
raise I18n.t('errors.messages.resource_not_found', resource: ::Companies::Company.model_name.human)
raise ActiveRecord::RecordNotFound, I18n.t('errors.messages.resource_not_found', resource: ::Companies::Company.model_name.human)
end

company.attributes = attributes.to_h
Expand Down
5 changes: 5 additions & 0 deletions app/graphql/types/mutation_type.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ class MutationType < Types::BaseObject
implements ::Types::GraphqlAuth

# Mutations
field :update_user, mutation: Mutations::UpdateUser
field :update_user_role, mutation: Mutations::UpdateUserRole
field :delete_user, mutation: Mutations::DeleteUser

# Company
field :update_company, mutation: Mutations::Companies::UpdateCompany
end
end
6 changes: 3 additions & 3 deletions config/initializers/cors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@

# origins '*'
resource '*',
:headers => :any,
:expose => ['Authorization'],
:methods => [:get, :post, :options, :delete, :put]
headers: :any,
expose: ['Authorization'],
methods: %i[get post options delete put]
end
end
4 changes: 4 additions & 0 deletions config/initializers/graphql_errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
nil
end

rescue_from CanCan::AccessDenied do |exception|
GraphQL::ExecutionError.new(exception.message)
end

rescue_from ActiveRecord::RecordInvalid do |exception|
GraphQL::ExecutionError.new(exception.record.errors.full_messages.join("\n"))
end
Expand Down

0 comments on commit 26b86cc

Please sign in to comment.