Skip to content

Commit

Permalink
update_account mutation: display error when user is not logged in
Browse files Browse the repository at this point in the history
  • Loading branch information
bricesanchez committed Feb 19, 2019
1 parent 8ad9750 commit 5b627ea
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/graphql/mutations/auth/update_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@ class Mutations::Auth::UpdateAccount < GraphQL::Schema::Mutation

def resolve(args)
user = context[:current_user]

if user.blank?
return {
errors: [
{ field: :_error, message: I18n.t('devise.failure.unauthenticated') }
],
success: false,
user: nil
}
end

user.update_with_password args

if user.errors.any?
Expand Down

0 comments on commit 5b627ea

Please sign in to comment.