Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup password field if it's not set #2

Open
BDav24 opened this issue Mar 15, 2021 · 0 comments
Open

Cleanup password field if it's not set #2

BDav24 opened this issue Mar 15, 2021 · 0 comments

Comments

@BDav24
Copy link

BDav24 commented Mar 15, 2021

When I click on "Change password", then "Cancel", the password param is sent with an empty value, which gives the error: no such column: password

I suggest changing encryptPassword function to:

const encryptPassword: Before = async (request) => {
  const { method } = request
  const { [passwordProperty]: newPassword, ...rest } = request.payload || {}

  if (method === 'post') {
    return {
      ...request,
      payload: {
        ...rest,
        ...(newPassword ? { [encryptedPasswordProperty]: await hash(newPassword) } : null)
      },
    }
  }
  return request
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant