@loomcore/api 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,9 +2,9 @@ import { Client } from "pg";
|
|
|
2
2
|
import { IMigration } from "../index.js";
|
|
3
3
|
export declare class CreateAdminUserMigration implements IMigration {
|
|
4
4
|
private readonly client;
|
|
5
|
-
private readonly
|
|
5
|
+
private readonly adminEmail;
|
|
6
6
|
private readonly adminPassword;
|
|
7
|
-
constructor(client: Client,
|
|
7
|
+
constructor(client: Client, adminEmail: string, adminPassword: string);
|
|
8
8
|
index: number;
|
|
9
9
|
execute(_orgId?: string): Promise<{
|
|
10
10
|
success: boolean;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { PostgresDatabase } from "../index.js";
|
|
2
2
|
import { randomUUID } from "crypto";
|
|
3
3
|
import { UserService } from "../../../services/user.service.js";
|
|
4
|
-
import { getSystemUserContext } from "@loomcore/common/models";
|
|
4
|
+
import { getSystemUserContext, initializeSystemUserContext } from "@loomcore/common/models";
|
|
5
5
|
export class CreateAdminUserMigration {
|
|
6
6
|
client;
|
|
7
|
-
|
|
7
|
+
adminEmail;
|
|
8
8
|
adminPassword;
|
|
9
|
-
constructor(client,
|
|
9
|
+
constructor(client, adminEmail, adminPassword) {
|
|
10
10
|
this.client = client;
|
|
11
|
-
this.
|
|
11
|
+
this.adminEmail = adminEmail;
|
|
12
12
|
this.adminPassword = adminPassword;
|
|
13
13
|
}
|
|
14
14
|
index = 6;
|
|
@@ -17,11 +17,12 @@ export class CreateAdminUserMigration {
|
|
|
17
17
|
try {
|
|
18
18
|
const database = new PostgresDatabase(this.client);
|
|
19
19
|
const userService = new UserService(database);
|
|
20
|
+
initializeSystemUserContext(this.adminEmail, _orgId);
|
|
20
21
|
const systemUserContext = getSystemUserContext();
|
|
21
22
|
const adminUser = await userService.create(systemUserContext, {
|
|
22
23
|
_id: _id,
|
|
23
24
|
_orgId: _orgId,
|
|
24
|
-
email: this.
|
|
25
|
+
email: this.adminEmail,
|
|
25
26
|
password: this.adminPassword,
|
|
26
27
|
firstName: 'Admin',
|
|
27
28
|
lastName: 'User',
|