Skip to content
This repository was archived by the owner on Dec 19, 2019. It is now read-only.

Allow changing logged in customers password with Graphql mutation #150

Merged
merged 2 commits into from
Sep 20, 2018
Merged

Allow changing logged in customers password with Graphql mutation #150

merged 2 commits into from
Sep 20, 2018

Conversation

austris-argalis
Copy link
Contributor

Description

Added a resolver which updates customer password. In response returns Customer object (not sure whether this is necessary).

Fixed Issues (if relevant)

  1. [Mutations] My Account: Change Password #54 : [Mutations] My Account: Change Password

Manual testing scenarios

  1. Create a new user account from store front-end or admin
  2. Acquire authorization with store (example uses session cookie)
  3. Execute a graphql query like:
    curl -XPOST -H "Content-Type: application/json" -b PHPSESSID=d4d1cbf0ad346103fffc1b71d8059bc7 \ -d '{"query": "mutation {changePassword(currentPassword: \"password\", newPassword: \"newPassword123\") {id, email, firstname, lastname}}","variables": [],"operationName": null}' \ http://magento23.local/graphql
  4. Ensure response has no errors and contain requested customer data

Contribution checklist

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • All automated tests passed successfully (all builds on Travis CI are green)

@magento-cicd2
Copy link
Contributor

magento-cicd2 commented Aug 12, 2018

CLA assistant check
All committers have signed the CLA.

@@ -5,6 +5,10 @@ type Query {
customer: Customer @resolver(class: "Magento\\CustomerGraphQl\\Model\\Resolver\\Customer") @doc(description: "The customer query returns information about a customer account")
}

type Mutation {
changePassword(currentPassword: String!, newPassword: String!): Customer @resolver(class: "\\Magento\\CustomerGraphQl\\Model\\Resolver\\Customer\\Account\\ChangePassword") @doc(description:"Changes password for logged in customer")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this mutation is in global scope, it is better to name it changeCustomerPassword

}
}

public function testGuestUserCannotChangePassword()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to make sure that the password can be changed only if correct current password was specified.

Copy link
Contributor

@paliarush paliarush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@austris-argalis thank you for contribution, please see several comments above.

@austris-argalis
Copy link
Contributor Author

@paliarush thanks for review!
Renamed the mutation and added a new test case with a valid session but incorrect current pw in the change request.

@naydav
Copy link
Contributor

naydav commented Aug 16, 2018

Hello, @austris-argalis
Can you ping me (vnayda) in Slack channel?
Thanks

@naydav
Copy link
Contributor

naydav commented Sep 13, 2018

Hello, @austris-argalis

Pls check CustomerChangePasswordTest

CustomerChangePasswordTest testCannotChangeWithIncorrectPassword History | REST EE | < 1 sec
-- | -- | --
Magento\GraphQl\Customer\CustomerChangePasswordTest::testCannotChangeWithIncorrectPassword Failed asserting that exception message 'GraphQL response contains errors: Internal server error ' matches '/The password doesn't match this account. Verify the password.*/'.
  | Failed | CustomerChangePasswordTest testChangeWeakPassword History | REST EE | < 1 sec
Magento\GraphQl\Customer\CustomerChangePasswordTest::testChangeWeakPassword Failed asserting that exception message 'GraphQL response contains errors: Internal server error ' matches '/Minimum of different classes of characters in password is.*/'.
  | Failed | CustomerChangePasswordTest testCannotChangeWithIncorrectPassword History | SOAP EE | < 1 sec
Magento\GraphQl\Customer\CustomerChangePasswordTest::testCannotChangeWithIncorrectPassword Failed asserting that exception message 'GraphQL response contains errors: Internal server error ' matches '/The password doesn't match this account. Verify the password.*/'.
  | Failed | CustomerChangePasswordTest testChangeWeakPassword History | SOAP EE | < 1 sec
Magento\GraphQl\Customer\CustomerChangePasswordTest::testChangeWeakPassword Failed asserting that exception message 'GraphQL response contains errors: Internal server error ' matches '/Minimum of different classes of characters in password is.*/'.


@naydav naydav removed the Imported label Sep 17, 2018
@austris-argalis
Copy link
Contributor Author

Hey, @naydav
I re-run tests after rebasing on the latest code from 2.3-dev branch and everything was still green.

Is there something specific about the env this output is from that could help me with debugging?
I see the actual error is

Internal server error

but don't know how to reproduce such conditions.

@naydav
Copy link
Contributor

naydav commented Sep 18, 2018

@austris-argalis
Looks like these tests are failed on Magento internal builds
I am going to recheck them

@magento-engcom-team magento-engcom-team merged commit e6043eb into magento:2.3-develop Sep 20, 2018
magento-engcom-team added a commit that referenced this pull request Nov 29, 2018
 - Merge Pull Request magento-engcom/import-export-improvements#150 from denispapec/import-export-improvements:phpstan-cleanuphistoryfile
 - Merged commits:
   1. dd8625e
@naydav naydav removed this from the Release: 2.3.0 milestone Dec 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants