We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
isAuthenticated
While using @adonisjs/auth, I followed the documentation to write a custom auth guard. It works great, but there's a small issue:
after ctx.auth.authenticateUsing(['myCustomGuard']), the ctx.auth.isAuthenticated is still false
ctx.auth.authenticateUsing(['myCustomGuard'])
ctx.auth.isAuthenticated
false
So, I checked the code for the access_tokens_guard. In its authenticate method, there is a snippet to update the local state:
access_tokens_guard
/** * Update local state */ this.isAuthenticated = true this.user = providerUser.getOriginal() as UserProvider[typeof PROVIDER_REAL_USER] & { currentAccessToken: AccessToken } this.user!.currentAccessToken = token /** * Notify */ this.#emitter.emit('access_tokens_auth:authentication_succeeded', { ctx: this.#ctx, token, guardName: this.#name, user: this.user, }) return this.user
But in tutorial, it's not mentioned:
this.user = providerUser.getOriginal() return this.getUserOrFail()
After I added this line, it worked:
this.isAuthenticated = true
However, I wounder if I still missed something, and how to improve the documentation?
The text was updated successfully, but these errors were encountered:
No branches or pull requests
While using @adonisjs/auth, I followed the documentation to write a custom auth guard. It works great, but there's a small issue:
after
ctx.auth.authenticateUsing(['myCustomGuard'])
, thectx.auth.isAuthenticated
is stillfalse
So, I checked the code for the
access_tokens_guard
. In its authenticate method, there is a snippet to update the local state:But in tutorial, it's not mentioned:
After I added this line, it worked:
However, I wounder if I still missed something, and how to improve the documentation?
The text was updated successfully, but these errors were encountered: