-
-
Notifications
You must be signed in to change notification settings - Fork 115
Open
Description
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
So, I checked the code for the access_tokens_guard. In its authenticate method, there is a snippet to update the local state:
/**
* 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.userBut in tutorial, it's not mentioned:
this.user = providerUser.getOriginal()
return this.getUserOrFail()After I added this line, it worked:
this.isAuthenticated = trueHowever, I wounder if I still missed something, and how to improve the documentation?
BakauDesign
Metadata
Metadata
Assignees
Labels
No labels