Commit f3cf4a0 1 parent 0b871ad commit f3cf4a0 Copy full SHA for f3cf4a0
File tree 2 files changed +10
-1
lines changed
2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1
1
import { Module } from '@nestjs/common' ;
2
2
import { MongooseModule } from '@nestjs/mongoose' ;
3
+ import { PassportModule } from '@nestjs/passport' ;
3
4
import { Tariff , TariffSchema } from 'src/user/schemas/tariff.schema' ;
4
5
import { User , UserSchema } from 'src/user/schemas/user.schema' ;
5
6
import { AuthService } from './auth.service' ;
6
7
7
8
@Module ( {
8
9
imports : [
10
+ PassportModule ,
9
11
MongooseModule . forFeature ( [
10
12
{ name : User . name , schema : UserSchema } ,
11
13
{ name : Tariff . name , schema : TariffSchema } ,
12
14
] ) ,
13
15
] ,
14
16
providers : [ AuthService ] ,
17
+ exports : [ AuthService ] ,
15
18
} )
16
19
export class AuthModule { }
Original file line number Diff line number Diff line change @@ -16,7 +16,13 @@ export class AuthService {
16
16
async findUserByToken ( token : string ) : Promise < UserDocument & { tariffId : TariffDocument } > {
17
17
// @ts -ignore
18
18
const tokenUuid = ApiKey . toUUID ( token ) ;
19
+ const user : UserDocument & { tariffId : TariffDocument } = await this . userRepository
20
+ . findOne ( { token : tokenUuid } )
21
+ . populate ( 'tariffId' )
22
+ . lean ( ) ;
19
23
20
- return this . userRepository . findOne ( { token : tokenUuid } , { populate : 'tariffId' } ) ;
24
+ if ( user ?. token === tokenUuid ) return user ;
25
+
26
+ return null ;
21
27
}
22
28
}
You can’t perform that action at this time.
0 commit comments