Skip to content

Instantly share code, notes, and snippets.

@smmoosavi
Last active December 27, 2017 11:11
Show Gist options
  • Save smmoosavi/7bb5e3ce7adc9b76f6c6da45f63b40e5 to your computer and use it in GitHub Desktop.
Save smmoosavi/7bb5e3ce7adc9b76f6c6da45f63b40e5 to your computer and use it in GitHub Desktop.

Revisions

  1. smmoosavi revised this gist May 26, 2017. 2 changed files with 3 additions and 2 deletions.
    3 changes: 2 additions & 1 deletion code.py
    Original file line number Diff line number Diff line change
    @@ -8,4 +8,5 @@ def mutate_and_get_payload(cls, input, context, info):
    if not user.check_password(old_password):
    raise ResponseError(
    "Invalid Password",
    code='invalid_old_password')
    code='invalid_old_password')
    # ...
    2 changes: 1 addition & 1 deletion req.graphql
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ mutation {
    changePassword(input: {
    oldPassword: "wrongPassword"
    newPassword: "some-password"
    }){
    }) {
    success
    }
    }
  2. smmoosavi created this gist May 26, 2017.
    11 changes: 11 additions & 0 deletions code.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    @classmethod
    def mutate_and_get_payload(cls, input, context, info):
    user = context.user
    old_password = input.get('old_password')
    new_password = input.get('new_password')

    if user.has_usable_password():
    if not user.check_password(old_password):
    raise ResponseError(
    "Invalid Password",
    code='invalid_old_password')
    8 changes: 8 additions & 0 deletions req.graphql
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    mutation {
    changePassword(input: {
    oldPassword: "wrongPassword"
    newPassword: "some-password"
    }){
    success
    }
    }
    12 changes: 12 additions & 0 deletions res.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    {
    "errors": [
    {
    "message": "Invalid Password",
    "code": "invalid-old-password",
    "params": null
    }
    ],
    "data": {
    "changePassword": null
    }
    }