-
-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Add email validation in case of profile update #7304
Conversation
Hey @golya It would be great if you could add a test, which proofs that if we update a user and the email already exists, we expect a validation error to come back. You could add the test into the edit users section, see https://github.com/TryGhost/Ghost/blob/master/core/test/integration/api/api_users_spec.js#L449 Thanks for PR and for helping :) |
issue TryGhost#7256 - add email check in edit if necessary - edit method is refactored - getByEmail can accept "id" option. - add emailIsAlreadyInUse property to translations Signed-off-by: Ádám Gólya <adam.stork@gmail.com>
6538b16
to
e02c46e
Compare
} | ||
}, | ||
|
||
update: function update(data, options) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@@ -810,6 +828,9 @@ User = ghostBookshelf.Model.extend({ | |||
|
|||
return Users.forge(options).fetch(options).then(function then(users) { | |||
var userWithEmail = users.find(function findUser(user) { | |||
if (options.id && parseInt(options.id) === user.get('id')) { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
@golya Hey :) Will you finish this PR for the next |
@golya Hey. Would you like to finish your PR? |
@kirrg001 Hi, sorry but I am really busy nowadays. I hope I will have some time in the future, but I can not promise anything. :( |
No problem 👍 I am going to close the PR for now to keep github clean. Your branch does not get deleted. If somebody else want's to fix this issue, we still can look at this as reference. |
Will make suggested improvements and open another PR. |
closes TryGhost#7256 - original code changes made by @golya in TryGhost#7304 - refactored edit method in user model, pulled update method from public API to prevent confusion - added test coverage for existing email update in user model spec - removed API test, as the current API does not allow adding new users, so not possible to test updating existing one
issue #7256
Signed-off-by: Ádám Gólya adam.stork@gmail.com