@loomcore/api 0.1.121 → 0.1.124

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.
@@ -43,9 +43,11 @@ export class AuthService extends MultiTenantApiService {
43
43
  if (!passwordsMatch) {
44
44
  throw new BadRequestError('Invalid Credentials');
45
45
  }
46
+ const person = await this.personService.findOne(EmptyUserContext, { filters: { _id: { eq: user.personId } } });
46
47
  const authorizations = await getUserContextAuthorizations(this.database, user);
47
48
  const userContext = {
48
49
  user: user,
50
+ person: person ?? undefined,
49
51
  organization: organization ?? undefined,
50
52
  authorizations: authorizations
51
53
  };
@@ -120,13 +122,21 @@ export class AuthService extends MultiTenantApiService {
120
122
  if (activeRefreshToken) {
121
123
  const systemUserContext = getSystemUserContext();
122
124
  const user = await this.getById(systemUserContext, activeRefreshToken.userId);
125
+ const person = await this.personService.findOne(EmptyUserContext, { filters: { _id: { eq: user?.personId } } });
123
126
  const organization = await this.organizationService.findOne(EmptyUserContext, { filters: { _id: { eq: user?._orgId } } });
124
127
  const authorizations = await getUserContextAuthorizations(this.database, user);
125
- const userContext = {
128
+ let userContext = {
126
129
  user: user,
130
+ person: person ?? undefined,
127
131
  organization: organization ?? undefined,
128
132
  authorizations: authorizations
129
133
  };
134
+ if (user.personId) {
135
+ const person = await this.personService.getById(EmptyUserContext, user.personId);
136
+ if (person) {
137
+ userContext.person = person;
138
+ }
139
+ }
130
140
  tokens = await this.createNewTokens(userContext, activeRefreshToken);
131
141
  }
132
142
  return tokens;
@@ -1,7 +1,7 @@
1
- import { IAddress } from '@loomcore/common/models';
1
+ import { IAddressModel } from '@loomcore/common/models';
2
2
  declare function standardizeField(field: string | undefined | null): string | null;
3
- declare function getSingleLineAddress(address: IAddress): string | null;
4
- declare function addFormattedAddress(address: IAddress): IAddress;
3
+ declare function getSingleLineAddress(address: IAddressModel): string | null;
4
+ declare function addFormattedAddress(address: IAddressModel): IAddressModel;
5
5
  export declare const addressUtils: {
6
6
  getSingleLineAddress: typeof getSingleLineAddress;
7
7
  standardizeField: typeof standardizeField;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loomcore/api",
3
- "version": "0.1.121",
3
+ "version": "0.1.124",
4
4
  "private": false,
5
5
  "description": "Loom Core Api - An opinionated Node.js api using Typescript, Express, and MongoDb or PostgreSQL",
6
6
  "scripts": {
@@ -58,7 +58,7 @@
58
58
  "qs": "^6.15.0"
59
59
  },
60
60
  "peerDependencies": {
61
- "@loomcore/common": "^0.0.57",
61
+ "@loomcore/common": "^0.0.63",
62
62
  "@sinclair/typebox": "0.34.33",
63
63
  "cookie-parser": "^1.4.6",
64
64
  "cors": "^2.8.5",