You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I change my AuthService with method getUserByToken to scoped I am getting an error:
[Nest] 713 - 05/30/2019, 3:38 PM Unknown authentication strategy "bearer" +4390ms
If I change it back to singleton everzthing works as excepted
Input Code
import{Injectable,Scope}from'@nestjs/common';import{UserEntity}from'src/entity/UserEntity';import{Repository}from'typeorm';import{InjectRepository}from'@nestjs/typeorm';
@Injectable({// scope: Scope.REQUEST, // THIS IS THE LINE THAT CHANGE THE BEHAVIOUR})exportclassAuthService{constructor(
@InjectRepository(UserEntity)privatereadonlyuserRepository: Repository<UserEntity>,){}publicasyncgetUserByToken(token: string): Promise<UserEntity>{constuser=awaitthis.userRepository.findOne({where: {
token,},relations: ['role'],});returnuser;}}
Expected behavior
It should work with different scoping
Environment
Nest version: 6.2.4
For Tooling issues:
- Node version: 10.15.0
- Platform: Windows
The text was updated successfully, but these errors were encountered:
I have just noticed a very similar issue (#1870) and it looks like this behavior is by design. Is there any documentation/example of how to implement authorization in a multitenant application?
As you noticed, it's impossible to use passport for that. I'd rather recommend wiring up your own tailored auth mechanism (which should be fairly simple though). I'm not aware of any article at the moment unfortunately :(
Bug Report
Current behavior
When I change my AuthService with method getUserByToken to scoped I am getting an error:
[Nest] 713 - 05/30/2019, 3:38 PM Unknown authentication strategy "bearer" +4390ms
If I change it back to singleton everzthing works as excepted
Input Code
Expected behavior
It should work with different scoping
Environment
The text was updated successfully, but these errors were encountered: