@friggframework/core 2.0.0--canary.395.4cca0c3.0 → 2.0.0--canary.395.25f994b.0
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.
- package/package.json +5 -5
- package/user/tests/doubles/test-user-repository.js +12 -55
- package/user/tests/use-cases/get-user-from-bearer-token.test.js +2 -2
- package/user/tests/use-cases/login-user.test.js +6 -14
- package/user/use-cases/create-individual-user.js +11 -2
- package/user/use-cases/create-organization-user.js +11 -3
- package/user/use-cases/get-user-from-bearer-token.js +29 -2
- package/user/use-cases/login-user.js +40 -4
- package/user/user-repository.js +7 -43
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@friggframework/core",
|
|
3
3
|
"prettier": "@friggframework/prettier-config",
|
|
4
|
-
"version": "2.0.0--canary.395.
|
|
4
|
+
"version": "2.0.0--canary.395.25f994b.0",
|
|
5
5
|
"dependencies": {
|
|
6
6
|
"@hapi/boom": "^10.0.1",
|
|
7
7
|
"aws-sdk": "^2.1200.0",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
"uuid": "^9.0.1"
|
|
23
23
|
},
|
|
24
24
|
"devDependencies": {
|
|
25
|
-
"@friggframework/eslint-config": "2.0.0--canary.395.
|
|
26
|
-
"@friggframework/prettier-config": "2.0.0--canary.395.
|
|
27
|
-
"@friggframework/test": "2.0.0--canary.395.
|
|
25
|
+
"@friggframework/eslint-config": "2.0.0--canary.395.25f994b.0",
|
|
26
|
+
"@friggframework/prettier-config": "2.0.0--canary.395.25f994b.0",
|
|
27
|
+
"@friggframework/test": "2.0.0--canary.395.25f994b.0",
|
|
28
28
|
"@types/lodash": "4.17.15",
|
|
29
29
|
"@typescript-eslint/eslint-plugin": "^8.0.0",
|
|
30
30
|
"chai": "^4.3.6",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
},
|
|
54
54
|
"homepage": "https://github.com/friggframework/frigg#readme",
|
|
55
55
|
"description": "",
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "25f994b4ae76131e3c0f333b3d17211950254c54"
|
|
57
57
|
}
|
|
@@ -14,19 +14,11 @@ class TestUserRepository {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async findOrganizationUserById(userId) {
|
|
17
|
-
|
|
18
|
-
if (!orgUserDoc) {
|
|
19
|
-
throw Boom.unauthorized('Organization User Not Found');
|
|
20
|
-
}
|
|
21
|
-
return new User(null, orgUserDoc, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
17
|
+
return this.organizationUsers.get(userId);
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
async findIndividualUserById(userId) {
|
|
25
|
-
|
|
26
|
-
if (!individualUserDoc) {
|
|
27
|
-
throw Boom.unauthorized('Individual User Not Found');
|
|
28
|
-
}
|
|
29
|
-
return new User(individualUserDoc, null, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
21
|
+
return this.individualUsers.get(userId);
|
|
30
22
|
}
|
|
31
23
|
|
|
32
24
|
async createToken(userId, rawToken, minutes = 120) {
|
|
@@ -38,77 +30,42 @@ class TestUserRepository {
|
|
|
38
30
|
async createIndividualUser(params) {
|
|
39
31
|
const individualUserData = { id: `individual-${Date.now()}`, ...params };
|
|
40
32
|
this.individualUsers.set(individualUserData.id, individualUserData);
|
|
41
|
-
return
|
|
42
|
-
individualUserData,
|
|
43
|
-
null,
|
|
44
|
-
this.userConfig.usePassword,
|
|
45
|
-
this.userConfig.primary,
|
|
46
|
-
this.userConfig.individualUserRequired,
|
|
47
|
-
this.userConfig.organizationUserRequired
|
|
48
|
-
);
|
|
33
|
+
return individualUserData;
|
|
49
34
|
}
|
|
50
35
|
|
|
51
36
|
async createOrganizationUser(params) {
|
|
52
37
|
const orgUserData = { ...params, id: `org-${Date.now()}` };
|
|
53
38
|
this.organizationUsers.set(orgUserData.id, orgUserData);
|
|
54
|
-
return
|
|
55
|
-
null,
|
|
56
|
-
orgUserData,
|
|
57
|
-
this.userConfig.usePassword,
|
|
58
|
-
this.userConfig.primary,
|
|
59
|
-
this.userConfig.individualUserRequired,
|
|
60
|
-
this.userConfig.organizationUserRequired
|
|
61
|
-
);
|
|
39
|
+
return orgUserData;
|
|
62
40
|
}
|
|
63
41
|
|
|
64
42
|
async findIndividualUserByUsername(username) {
|
|
65
43
|
for (const userDoc of this.individualUsers.values()) {
|
|
66
44
|
if (userDoc.username === username) {
|
|
67
|
-
return
|
|
68
|
-
userDoc,
|
|
69
|
-
null,
|
|
70
|
-
this.userConfig.usePassword,
|
|
71
|
-
this.userConfig.primary,
|
|
72
|
-
this.userConfig.individualUserRequired,
|
|
73
|
-
this.userConfig.organizationUserRequired
|
|
74
|
-
);
|
|
45
|
+
return userDoc;
|
|
75
46
|
}
|
|
76
47
|
}
|
|
77
|
-
|
|
48
|
+
return null;
|
|
78
49
|
}
|
|
79
50
|
|
|
80
51
|
async findIndividualUserByAppUserId(appUserId) {
|
|
81
|
-
if (!appUserId)
|
|
52
|
+
if (!appUserId) return null;
|
|
82
53
|
for (const userDoc of this.individualUsers.values()) {
|
|
83
54
|
if (userDoc.appUserId === appUserId) {
|
|
84
|
-
return
|
|
85
|
-
userDoc,
|
|
86
|
-
null,
|
|
87
|
-
this.userConfig.usePassword,
|
|
88
|
-
this.userConfig.primary,
|
|
89
|
-
this.userConfig.individualUserRequired,
|
|
90
|
-
this.userConfig.organizationUserRequired
|
|
91
|
-
);
|
|
55
|
+
return userDoc;
|
|
92
56
|
}
|
|
93
57
|
}
|
|
94
|
-
|
|
58
|
+
return null;
|
|
95
59
|
}
|
|
96
60
|
|
|
97
61
|
async findOrganizationUserByAppOrgId(appOrgId) {
|
|
98
|
-
if (!appOrgId)
|
|
62
|
+
if (!appOrgId) return null;
|
|
99
63
|
for (const userDoc of this.organizationUsers.values()) {
|
|
100
64
|
if (userDoc.appOrgId === appOrgId) {
|
|
101
|
-
return
|
|
102
|
-
null,
|
|
103
|
-
userDoc,
|
|
104
|
-
this.userConfig.usePassword,
|
|
105
|
-
this.userConfig.primary,
|
|
106
|
-
this.userConfig.individualUserRequired,
|
|
107
|
-
this.userConfig.organizationUserRequired
|
|
108
|
-
);
|
|
65
|
+
return userDoc;
|
|
109
66
|
}
|
|
110
67
|
}
|
|
111
|
-
|
|
68
|
+
return null;
|
|
112
69
|
}
|
|
113
70
|
}
|
|
114
71
|
|
|
@@ -25,14 +25,14 @@ describe('GetUserFromBearerToken Use Case', () => {
|
|
|
25
25
|
it('should retrieve a user for a valid bearer token', async () => {
|
|
26
26
|
const userId = 'user-123';
|
|
27
27
|
const token = await userRepository.createToken(userId);
|
|
28
|
-
const
|
|
28
|
+
const createdUserData = await userRepository.createIndividualUser({
|
|
29
29
|
id: userId,
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
const user = await getUserFromBearerToken.execute(`Bearer ${token}`);
|
|
33
33
|
|
|
34
34
|
expect(user).toBeDefined();
|
|
35
|
-
expect(user.getId()).toBe(
|
|
35
|
+
expect(user.getId()).toBe(createdUserData.id);
|
|
36
36
|
});
|
|
37
37
|
|
|
38
38
|
it('should throw an unauthorized error if the bearer token is missing', async () => {
|
|
@@ -58,9 +58,6 @@ describe('LoginUser Use Case', () => {
|
|
|
58
58
|
it('should throw an unauthorized error for a non-existent user', async () => {
|
|
59
59
|
const username = 'non-existent-user';
|
|
60
60
|
const password = 'password123';
|
|
61
|
-
userRepository.findIndividualUserByUsername = jest
|
|
62
|
-
.fn()
|
|
63
|
-
.mockRejectedValue(new Error('user not found'));
|
|
64
61
|
|
|
65
62
|
await expect(
|
|
66
63
|
loginUser.execute({ username, password })
|
|
@@ -80,18 +77,19 @@ describe('LoginUser Use Case', () => {
|
|
|
80
77
|
|
|
81
78
|
it('should successfully retrieve a user by appUserId', async () => {
|
|
82
79
|
const appUserId = 'app-user-123';
|
|
83
|
-
const
|
|
80
|
+
const createdUserData = await userRepository.createIndividualUser({
|
|
84
81
|
appUserId,
|
|
85
82
|
});
|
|
86
83
|
|
|
87
84
|
const result = await loginUser.execute({ appUserId });
|
|
88
|
-
expect(result.getId()).toBe(
|
|
85
|
+
expect(result.getId()).toBe(createdUserData.id);
|
|
89
86
|
});
|
|
90
87
|
});
|
|
91
88
|
|
|
92
89
|
describe('With Organization User', () => {
|
|
93
90
|
beforeEach(() => {
|
|
94
91
|
userConfig = {
|
|
92
|
+
primary: 'organization',
|
|
95
93
|
individualUserRequired: false,
|
|
96
94
|
organizationUserRequired: true,
|
|
97
95
|
};
|
|
@@ -104,23 +102,20 @@ describe('LoginUser Use Case', () => {
|
|
|
104
102
|
|
|
105
103
|
it('should successfully retrieve an organization user by appOrgId', async () => {
|
|
106
104
|
const appOrgId = 'app-org-123';
|
|
107
|
-
const
|
|
105
|
+
const createdUserData = await userRepository.createOrganizationUser({
|
|
108
106
|
name: 'Test Org',
|
|
109
107
|
appOrgId,
|
|
110
108
|
});
|
|
111
109
|
|
|
112
110
|
const result = await loginUser.execute({ appOrgId });
|
|
113
|
-
expect(result.getId()).toBe(
|
|
111
|
+
expect(result.getId()).toBe(createdUserData.id);
|
|
114
112
|
});
|
|
115
113
|
|
|
116
114
|
it('should throw an unauthorized error for a non-existent organization user', async () => {
|
|
117
115
|
const appOrgId = 'non-existent-org';
|
|
118
|
-
userRepository.findOrganizationUserByAppOrgId = jest
|
|
119
|
-
.fn()
|
|
120
|
-
.mockRejectedValue(new Error('user not found'));
|
|
121
116
|
|
|
122
117
|
await expect(loginUser.execute({ appOrgId })).rejects.toThrow(
|
|
123
|
-
'user not found'
|
|
118
|
+
'org user non-existent-org not found'
|
|
124
119
|
);
|
|
125
120
|
});
|
|
126
121
|
});
|
|
@@ -132,9 +127,6 @@ describe('LoginUser Use Case', () => {
|
|
|
132
127
|
usePassword: false,
|
|
133
128
|
};
|
|
134
129
|
userRepository = new TestUserRepository({ userConfig });
|
|
135
|
-
userRepository.findIndividualUserByAppUserId = jest
|
|
136
|
-
.fn()
|
|
137
|
-
.mockRejectedValue(new Error('user not found'));
|
|
138
130
|
loginUser = new LoginUser({
|
|
139
131
|
userRepository,
|
|
140
132
|
userConfig,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const { get } = require('../../assertions');
|
|
2
2
|
const Boom = require('@hapi/boom');
|
|
3
|
+
const { User } = require('../user');
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Use case for creating an individual user.
|
|
@@ -38,14 +39,22 @@ class CreateIndividualUser {
|
|
|
38
39
|
const appUserId = get(params, 'appUserId', null);
|
|
39
40
|
const organizationUserId = get(params, 'organizationUserId', null);
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const individualUserData = await this.userRepository.createIndividualUser({
|
|
42
43
|
email,
|
|
43
44
|
username,
|
|
44
45
|
hashword,
|
|
45
46
|
appUserId,
|
|
46
47
|
organizationUser: organizationUserId,
|
|
47
48
|
});
|
|
48
|
-
|
|
49
|
+
|
|
50
|
+
return new User(
|
|
51
|
+
individualUserData,
|
|
52
|
+
null,
|
|
53
|
+
this.userConfig.usePassword,
|
|
54
|
+
this.userConfig.primary,
|
|
55
|
+
this.userConfig.individualUserRequired,
|
|
56
|
+
this.userConfig.organizationUserRequired
|
|
57
|
+
);
|
|
49
58
|
}
|
|
50
59
|
}
|
|
51
60
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { get } = require('../../assertions');
|
|
2
|
+
const { User } = require('../user');
|
|
2
3
|
|
|
3
|
-
// todo: this is not used anywhere, check if needed
|
|
4
4
|
/**
|
|
5
5
|
* Use case for creating an organization user.
|
|
6
6
|
* @class CreateOrganizationUser
|
|
@@ -27,12 +27,20 @@ class CreateOrganizationUser {
|
|
|
27
27
|
const name = get(params, 'name');
|
|
28
28
|
const appOrgId = get(params, 'appOrgId');
|
|
29
29
|
|
|
30
|
-
const
|
|
30
|
+
const organizationUserData =
|
|
31
31
|
await this.userRepository.createOrganizationUser({
|
|
32
32
|
name,
|
|
33
33
|
appOrgId,
|
|
34
34
|
});
|
|
35
|
-
|
|
35
|
+
|
|
36
|
+
return new User(
|
|
37
|
+
null,
|
|
38
|
+
organizationUserData,
|
|
39
|
+
this.userConfig.usePassword,
|
|
40
|
+
this.userConfig.primary,
|
|
41
|
+
this.userConfig.individualUserRequired,
|
|
42
|
+
this.userConfig.organizationUserRequired
|
|
43
|
+
);
|
|
36
44
|
}
|
|
37
45
|
}
|
|
38
46
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const Boom = require('@hapi/boom');
|
|
2
|
+
const { User } = require('../user');
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Use case for retrieving a user from a bearer token.
|
|
@@ -40,10 +41,36 @@ class GetUserFromBearerToken {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
if (this.userConfig.primary === 'organization') {
|
|
43
|
-
|
|
44
|
+
const organizationUserData = await this.userRepository.findOrganizationUserById(sessionToken.user);
|
|
45
|
+
|
|
46
|
+
if (!organizationUserData) {
|
|
47
|
+
throw Boom.unauthorized('Organization User Not Found');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return new User(
|
|
51
|
+
null,
|
|
52
|
+
organizationUserData,
|
|
53
|
+
this.userConfig.usePassword,
|
|
54
|
+
this.userConfig.primary,
|
|
55
|
+
this.userConfig.individualUserRequired,
|
|
56
|
+
this.userConfig.organizationUserRequired
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const individualUserData = await this.userRepository.findIndividualUserById(sessionToken.user);
|
|
61
|
+
|
|
62
|
+
if (!individualUserData) {
|
|
63
|
+
throw Boom.unauthorized('Individual User Not Found');
|
|
44
64
|
}
|
|
45
65
|
|
|
46
|
-
return
|
|
66
|
+
return new User(
|
|
67
|
+
individualUserData,
|
|
68
|
+
null,
|
|
69
|
+
this.userConfig.usePassword,
|
|
70
|
+
this.userConfig.primary,
|
|
71
|
+
this.userConfig.individualUserRequired,
|
|
72
|
+
this.userConfig.organizationUserRequired
|
|
73
|
+
);
|
|
47
74
|
}
|
|
48
75
|
}
|
|
49
76
|
|
|
@@ -2,6 +2,7 @@ const Boom = require('@hapi/boom');
|
|
|
2
2
|
const {
|
|
3
3
|
RequiredPropertyError,
|
|
4
4
|
} = require('../../errors');
|
|
5
|
+
const { User } = require('../user');
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Use case for logging in a user.
|
|
@@ -46,22 +47,48 @@ class LoginUser {
|
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
+
const individualUserData =
|
|
50
51
|
await this.userRepository.findIndividualUserByUsername(
|
|
51
52
|
username
|
|
52
53
|
);
|
|
53
54
|
|
|
55
|
+
if (!individualUserData) {
|
|
56
|
+
throw Boom.unauthorized('user not found');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const individualUser = new User(
|
|
60
|
+
individualUserData,
|
|
61
|
+
null,
|
|
62
|
+
this.userConfig.usePassword,
|
|
63
|
+
this.userConfig.primary,
|
|
64
|
+
this.userConfig.individualUserRequired,
|
|
65
|
+
this.userConfig.organizationUserRequired
|
|
66
|
+
);
|
|
67
|
+
|
|
54
68
|
if (!individualUser.isPasswordValid(password)) {
|
|
55
69
|
throw Boom.unauthorized('Incorrect username or password');
|
|
56
70
|
}
|
|
57
71
|
|
|
58
72
|
return individualUser;
|
|
59
73
|
} else {
|
|
60
|
-
const
|
|
74
|
+
const individualUserData =
|
|
61
75
|
await this.userRepository.findIndividualUserByAppUserId(
|
|
62
76
|
appUserId
|
|
63
77
|
);
|
|
64
78
|
|
|
79
|
+
if (!individualUserData) {
|
|
80
|
+
throw Boom.unauthorized('user not found');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const individualUser = new User(
|
|
84
|
+
individualUserData,
|
|
85
|
+
null,
|
|
86
|
+
this.userConfig.usePassword,
|
|
87
|
+
this.userConfig.primary,
|
|
88
|
+
this.userConfig.individualUserRequired,
|
|
89
|
+
this.userConfig.organizationUserRequired
|
|
90
|
+
);
|
|
91
|
+
|
|
65
92
|
return individualUser;
|
|
66
93
|
}
|
|
67
94
|
}
|
|
@@ -69,13 +96,22 @@ class LoginUser {
|
|
|
69
96
|
|
|
70
97
|
if (this.userConfig.organizationUserRequired) {
|
|
71
98
|
|
|
72
|
-
const
|
|
99
|
+
const organizationUserData =
|
|
73
100
|
await this.userRepository.findOrganizationUserByAppOrgId(appOrgId);
|
|
74
101
|
|
|
75
|
-
if (!
|
|
102
|
+
if (!organizationUserData) {
|
|
76
103
|
throw Boom.unauthorized(`org user ${appOrgId} not found`);
|
|
77
104
|
}
|
|
78
105
|
|
|
106
|
+
const organizationUser = new User(
|
|
107
|
+
null,
|
|
108
|
+
organizationUserData,
|
|
109
|
+
this.userConfig.usePassword,
|
|
110
|
+
this.userConfig.primary,
|
|
111
|
+
this.userConfig.individualUserRequired,
|
|
112
|
+
this.userConfig.organizationUserRequired
|
|
113
|
+
);
|
|
114
|
+
|
|
79
115
|
return organizationUser;
|
|
80
116
|
}
|
|
81
117
|
|
package/user/user-repository.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
const { Token } = require('../database/models/Token');
|
|
2
2
|
const { IndividualUser } = require('../database/models/IndividualUser');
|
|
3
3
|
const { OrganizationUser } = require('../database/models/OrganizationUser');
|
|
4
|
-
const { User } = require('./user');
|
|
5
|
-
const Boom = require('@hapi/boom');
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
//todo: the user class instantiation needs to happen in each use case and not here.
|
|
9
5
|
class UserRepository {
|
|
10
6
|
/**
|
|
11
7
|
* @param {Object} userConfig - The user config in the app definition.
|
|
@@ -26,23 +22,11 @@ class UserRepository {
|
|
|
26
22
|
}
|
|
27
23
|
|
|
28
24
|
async findOrganizationUserById(userId) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!organizationUser) {
|
|
32
|
-
throw Boom.unauthorized('Organization User Not Found');
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return new User(null, organizationUser, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
25
|
+
return this.OrganizationUser.findById(userId);
|
|
36
26
|
}
|
|
37
27
|
|
|
38
28
|
async findIndividualUserById(userId) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
if (!individualUser) {
|
|
42
|
-
throw Boom.unauthorized('Individual User Not Found');
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return new User(individualUser, null, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
29
|
+
return this.IndividualUser.findById(userId);
|
|
46
30
|
}
|
|
47
31
|
|
|
48
32
|
async createToken(userId, rawToken, minutes = 120) {
|
|
@@ -55,43 +39,23 @@ class UserRepository {
|
|
|
55
39
|
}
|
|
56
40
|
|
|
57
41
|
async createIndividualUser(params) {
|
|
58
|
-
|
|
59
|
-
return new User(individualUser, null, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
42
|
+
return this.IndividualUser.create(params);
|
|
60
43
|
}
|
|
61
44
|
|
|
62
45
|
async createOrganizationUser(params) {
|
|
63
|
-
|
|
64
|
-
return new User(null, organizationUser, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
46
|
+
return this.OrganizationUser.create(params);
|
|
65
47
|
}
|
|
66
48
|
|
|
67
49
|
async findIndividualUserByUsername(username) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if (!individualUser) {
|
|
71
|
-
throw Boom.unauthorized('user not found');
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
return new User(individualUser, null, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
50
|
+
return this.IndividualUser.findOne({ username });
|
|
75
51
|
}
|
|
76
52
|
|
|
77
53
|
async findIndividualUserByAppUserId(appUserId) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
if (!individualUser) {
|
|
81
|
-
throw Boom.unauthorized('user not found');
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return new User(individualUser, null, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
54
|
+
return this.IndividualUser.getUserByAppUserId(appUserId);
|
|
85
55
|
}
|
|
86
56
|
|
|
87
57
|
async findOrganizationUserByAppOrgId(appOrgId) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
if (!organizationUser) {
|
|
91
|
-
throw Boom.unauthorized('user not found');
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
return new User(null, organizationUser, this.userConfig.usePassword, this.userConfig.primary, this.userConfig.individualUserRequired, this.userConfig.organizationUserRequired);
|
|
58
|
+
return this.OrganizationUser.getUserByAppOrgId(appOrgId);
|
|
95
59
|
}
|
|
96
60
|
}
|
|
97
61
|
|