Closed kylanhurt closed 1 year ago
Your User
model does not have a rememberMeToken column and neither the database table has this column. Agree the error message can be improved, but it is not a bug.
Please update your model and table and then give it a try. Feel free to re-open the issue if the problem persists
@thetutlage Could you elaborate on this? Is it as simple as removing the references to remember_me_token
from the DB migration file? Does this mean that the "rememberMe" functionality is not possible to use with Lucid? Because if I remove it from the DB (it was not present anywhere on the User model), I still get the same error.
It means, if you want to use rememberMe
feature, then your model and table should have this column
Update: looks like this latest issue after adding the column to the User model was that I used snake case (remember_me_token
) instead of camel case (rememberMeToken
)
@thetutlage Sorry, I know this is probably a very tedious process for you. I misread your earlier comment. I have adjusted my repo accordingly but am still getting the same issue. In fact, when I log the providerUser
in the updateRememberMeToken
method it seems that the providerUser.user.$dirty
property is missing. This is what providerUser.user
logs out:
User {
modelOptions: {
connection: 'pg',
profiler: Profiler {
appRoot: '/Users/kylan/Documents/adonis/auth-attempt',
logger: [Logger],
config: [Object]
}
},
modelTrx: undefined,
transactionListener: [Function: bound listener],
fillInvoked: false,
cachedGetters: {},
forceUpdate: false,
'$columns': {},
'$attributes': { id: 1, account_name: 'kylan', remember_me_token: null },
'$original': { id: 1, account_name: 'kylan', remember_me_token: null },
'$preloaded': {},
'$extras': {},
'$sideloaded': {},
'$isPersisted': true,
'$isDeleted': false,
'$isLocal': false,
rememberMeToken: 'vxXL0TDXoQf2iYFXU1VN'
}
As you can see the remember_me_token
attribute appears to be included, although the $columns
object seems to be empty. Is there something wrong with my project's configuration or something?
Here is the updated commit:
https://github.com/telos-crew/adonis-lucid-auth/commit/66485fbcf0f908ccb1e5601e21ed7a27aabb8c2d
There is no remember me column in this model https://github.com/telos-crew/adonis-lucid-auth/blob/649927491c79635b80332ba66dcba2c95f008917/app/Models/User.ts.
Please, read a little of about how remember me works with login and sessions and then try to update your code accordingly.
Package version
8.2.3
Node.js and npm version
16.19.0 and 8.19.3
BONUS (a sample repo to reproduce the issue)
https://github.com/telos-crew/adonis-lucid-auth/tree/649927491c79635b80332ba66dcba2c95f008917
Sample Code (to reproduce the issue)
This specifically occurs when doing the
await auth.use('web').login(user, true)
line in AuthController.tsAuthController.ts
config/auth.ts
contracts/auth.ts