@loomcore/api 0.0.29 → 0.0.31
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.
|
@@ -29,6 +29,9 @@ export async function initSystemUserContext(db) {
|
|
|
29
29
|
const { OrganizationService } = await import('../services/organization.service.js');
|
|
30
30
|
const organizationService = new OrganizationService(db);
|
|
31
31
|
const metaOrg = await organizationService.getMetaOrg(EmptyUserContext);
|
|
32
|
+
if (!metaOrg) {
|
|
33
|
+
throw new Error('Meta organization not found. Please create an organization with isMetaOrg=true before starting the API.');
|
|
34
|
+
}
|
|
32
35
|
metaOrgId = metaOrg._id;
|
|
33
36
|
}
|
|
34
37
|
initializeSystemUserContext(systemEmail, metaOrgId);
|
|
@@ -22,6 +22,7 @@ export class AuthService extends GenericApiService {
|
|
|
22
22
|
async attemptLogin(req, res, email, password) {
|
|
23
23
|
const lowerCaseEmail = email.toLowerCase();
|
|
24
24
|
const user = await this.getUserByEmail(lowerCaseEmail);
|
|
25
|
+
console.log(`In attemptLogin, user: ${JSON.stringify(user)}`);
|
|
25
26
|
if (!user) {
|
|
26
27
|
throw new BadRequestError('Invalid Credentials');
|
|
27
28
|
}
|
|
@@ -33,6 +34,7 @@ export class AuthService extends GenericApiService {
|
|
|
33
34
|
user: user,
|
|
34
35
|
_orgId: user._orgId
|
|
35
36
|
};
|
|
37
|
+
console.log(`In attemptLogin, userContext: ${JSON.stringify(userContext)}`);
|
|
36
38
|
const deviceId = this.getAndSetDeviceIdCookie(req, res);
|
|
37
39
|
const loginResponse = await this.logUserIn(userContext, deviceId);
|
|
38
40
|
return loginResponse;
|
|
@@ -51,7 +53,8 @@ export class AuthService extends GenericApiService {
|
|
|
51
53
|
};
|
|
52
54
|
this.updateLastLoggedIn(userContext.user._id)
|
|
53
55
|
.catch(err => console.log(`Error updating lastLoggedIn: ${err}`));
|
|
54
|
-
this.transformSingle(userContext.user);
|
|
56
|
+
userContext.user = this.transformSingle(userContext.user);
|
|
57
|
+
console.log(`In logUserIn, userContext: ${JSON.stringify(userContext)}`);
|
|
55
58
|
loginResponse = { tokens: tokenResponse, userContext };
|
|
56
59
|
}
|
|
57
60
|
return loginResponse;
|