Replies: 1 comment
-
i've got solution, here's the details: adonisjs/lucid#1044 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
If I create a user from factories, I cannot login because of the error
database.exists()
for my email field, but strangely, if I create a user using an HTTP method request, there's no error, thus I can login as expected.The error must be from my
loginValidator
, which has the methodexists()
. I put the method there because my assumption on how it works was that the method should be validating if my email exists or not, or so I thought on how it really works. I can't get the explanation in Lucid nor Vinejs documentation, but I found it from a file database provider in Lucid modules.Lucid documentation only said that Adonis is extending Vinejs validation with these two methods,
unique()
andexists()
, but no detail on how both work, and I wanted to use both, the former for myregisterValidator
and the latter for myloginValidator
.At first, when I'm trying to register and login using the API, it works just fine; only when I'm using the user from the factory, both methods work oppositely.
database.exists
error.database.unique
error, but if it's a factory-created user's email, I can get the auth token, and then there will be another user with the same email inside the databasesc
User models:
User table:
user factory
auth validator
auth controller
This is my repo with the branch specifically for this problem: https://github.com/fzhnf/api-endpoint-adonis/tree/feature/User-factory
Beta Was this translation helpful? Give feedback.
All reactions