make runValidation in updateProfile
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
Hey @yariksav! 👋
Sorry for getting late on this, what's your issue?
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"
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.
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 https://github.com/adonisjs/adonis-persona/issues/11