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

make runValidation in updateProfile #16

Open
yariksav opened this issue Jul 17, 2018 · 4 comments
Open

make runValidation in updateProfile #16

yariksav opened this issue Jul 17, 2018 · 4 comments
Assignees

Comments

@yariksav
Copy link

It would be great to have auto validation on existance uids in updateProfile, same as runValidation in register
https://github.com/adonisjs/adonis-persona/blob/b28c5231c4355f8a11a2e357e90807ffd77ab70b/src/Persona.js#L632

@yariksav yariksav changed the title run validation on existance when some of uids is changed in updateProfile make runValidation in updateProfile Jul 17, 2018
@RomainLanz
Copy link
Member

Hey @yariksav! 👋

Sorry for getting late on this, what's your issue?

@yariksav
Copy link
Author

Because when I execute
Persona.updateProfile(auth.user, payload)
where username was changed to already exists in other user i receive sql error:
update "users" set "username"= $1, "created_at" = $2, "updated_at" = $3 where "id" = $4 - duplicate key value violates unique constraint "users_username_unique"

@RomainLanz
Copy link
Member

You need to run yourself validation on this query.
We cannot run validation here because we don't know what you want to change.

Also, you need to handle this type of exception, since between the validation and the save someone could make the change.

@thetutlage
Copy link
Member

I believe, Persona can be improve here. Let me create an RFC explaining the changes we can make to improve the overall flow of persona including #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants