@@ -21,6 +21,7 @@ import { ConfigService, ILogger, Logger } from '../../core';
21
21
import { ForgotPassword } from '../../core/email/templates' ;
22
22
import { Privileges , rolesForScope , withoutScope } from '../authorization' ;
23
23
import { AssignableRoles } from '../authorization/dto/assignable-roles' ;
24
+ import { ActorRepository } from '../user/actor.repository' ;
24
25
import { AuthenticationRepository } from './authentication.repository' ;
25
26
import { CryptoService } from './crypto.service' ;
26
27
import { LoginInput , RegisterInput , ResetPasswordInput } from './dto' ;
@@ -40,6 +41,7 @@ export class AuthenticationService {
40
41
@Logger ( 'authentication:service' ) private readonly logger : ILogger ,
41
42
private readonly repo : AuthenticationRepository ,
42
43
private readonly edgedb : EdgeDB ,
44
+ private readonly actors : ActorRepository ,
43
45
private readonly moduleRef : ModuleRef ,
44
46
) { }
45
47
@@ -116,7 +118,10 @@ export class AuthenticationService {
116
118
117
119
const { iat } = this . decodeJWT ( token ) ;
118
120
119
- const result = await this . repo . resumeSession ( token , impersonatee ?. id ) ;
121
+ const [ result , anon ] = await Promise . all ( [
122
+ this . repo . resumeSession ( token , impersonatee ?. id ) ,
123
+ this . actors . getAnonymous ( ) ,
124
+ ] ) ;
120
125
121
126
if ( ! result ) {
122
127
this . logger . debug ( 'Failed to find active token in database' , { token } ) ;
@@ -140,7 +145,7 @@ export class AuthenticationService {
140
145
const requesterSession : Session = {
141
146
token,
142
147
issuedAt : DateTime . fromMillis ( iat ) ,
143
- userId : result . userId ?? ( 'anonuserid' as ID ) ,
148
+ userId : result . userId ?? anon . id ,
144
149
anonymous : ! result . userId ,
145
150
roles : result . roles ,
146
151
} ;
0 commit comments