@@ -3,11 +3,16 @@ import { ID, Role } from '~/common';
3
3
import { RootUserAlias } from '~/core/config/root-user.config' ;
4
4
import { disableAccessPolicies , e , EdgeDB } from '~/core/edgedb' ;
5
5
import { AuthenticationRepository } from '../authentication/authentication.repository' ;
6
+ import { ActorRepository } from '../user/actor.repository' ;
6
7
7
8
@Injectable ( )
8
9
export class AdminEdgeDBRepository {
9
10
private readonly db : EdgeDB ;
10
- constructor ( edgedb : EdgeDB , readonly auth : AuthenticationRepository ) {
11
+ constructor (
12
+ edgedb : EdgeDB ,
13
+ readonly auth : AuthenticationRepository ,
14
+ readonly actors : ActorRepository ,
15
+ ) {
11
16
this . db = edgedb . withOptions ( disableAccessPolicies ) ;
12
17
}
13
18
@@ -33,6 +38,8 @@ export class AdminEdgeDBRepository {
33
38
}
34
39
35
40
async createRootUser ( id : ID , email : string , passwordHash : string ) {
41
+ const ghost = await this . actors . getGhost ( ) ;
42
+
36
43
const newUser = e . insert ( e . User , {
37
44
id,
38
45
email,
@@ -45,8 +52,12 @@ export class AdminEdgeDBRepository {
45
52
target : newUser ,
46
53
} ) ;
47
54
await this . db
48
- // eslint-disable-next-line @typescript-eslint/naming-convention
49
- . withOptions ( ( o ) => o . withConfig ( { allow_user_specified_id : true } ) )
55
+ . withOptions ( ( o ) =>
56
+ o
57
+ // eslint-disable-next-line @typescript-eslint/naming-convention
58
+ . withConfig ( { allow_user_specified_id : true } )
59
+ . withGlobals ( { currentActorId : ghost . id } ) ,
60
+ )
50
61
. run ( query ) ;
51
62
await this . auth . savePasswordHashOnUser ( id , passwordHash ) ;
52
63
}
0 commit comments