@drax/identity-back 0.40.0 → 0.43.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/dist/controllers/UserController.js +2 -8
- package/dist/middleware/rbacMiddleware.js +2 -0
- package/dist/routes/UserAvatarRoutes.js +1 -1
- package/dist/services/RoleService.js +0 -1
- package/dist/services/TenantService.js +0 -1
- package/dist/services/UserApiKeyService.js +0 -1
- package/dist/services/UserService.js +0 -1
- package/dist/setup/CreateOrUpdateRole.js +0 -1
- package/package.json +7 -7
- package/src/controllers/UserController.ts +1 -7
- package/src/middleware/rbacMiddleware.ts +2 -0
- package/src/services/RoleService.ts +0 -1
- package/src/services/TenantService.ts +0 -1
- package/src/services/UserApiKeyService.ts +0 -1
- package/src/services/UserService.ts +0 -1
- package/src/setup/CreateOrUpdateRole.ts +0 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types/controllers/UserController.d.ts.map +1 -1
- package/types/middleware/rbacMiddleware.d.ts.map +1 -1
- package/types/services/RoleService.d.ts.map +1 -1
- package/types/services/TenantService.d.ts.map +1 -1
- package/types/services/UserApiKeyService.d.ts.map +1 -1
- package/types/services/UserService.d.ts.map +1 -1
- package/types/setup/CreateOrUpdateRole.d.ts.map +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractFastifyController } from "@drax/crud-back";
|
|
2
2
|
import RegistrationCompleteHtml from "../html/RegistrationCompleteHtml.js";
|
|
3
|
-
import { CommonConfig, DraxConfig, StoreManager, ValidationError, UnauthorizedError, SecuritySensitiveError,
|
|
3
|
+
import { CommonConfig, DraxConfig, StoreManager, ValidationError, UnauthorizedError, SecuritySensitiveError, } from "@drax/common-back";
|
|
4
4
|
import UserServiceFactory from "../factory/UserServiceFactory.js";
|
|
5
5
|
import RoleServiceFactory from "../factory/RoleServiceFactory.js";
|
|
6
6
|
import UserPermissions from "../permissions/UserPermissions.js";
|
|
@@ -116,13 +116,7 @@ class UserController extends AbstractFastifyController {
|
|
|
116
116
|
request.rbac.assertPermission(UserPermissions.SwitchTenant);
|
|
117
117
|
if (request.authUser && request.token) {
|
|
118
118
|
const tenantId = request.body.tenantId;
|
|
119
|
-
|
|
120
|
-
throw new BadRequestError('Missing tenantId');
|
|
121
|
-
}
|
|
122
|
-
const tenant = await TenantServiceFactory().findById(tenantId);
|
|
123
|
-
if (!tenant) {
|
|
124
|
-
throw new BadRequestError('Invalid tenantId');
|
|
125
|
-
}
|
|
119
|
+
const tenant = tenantId ? await TenantServiceFactory().findById(tenantId) : undefined;
|
|
126
120
|
const tenantName = tenant?.name;
|
|
127
121
|
const userService = UserServiceFactory();
|
|
128
122
|
let { accessToken } = await userService.switchTenant(request.token, tenantId, tenantName);
|
|
@@ -17,10 +17,12 @@ async function rbacMiddleware(request, reply) {
|
|
|
17
17
|
const role = await draxCache.getOrLoad(cacheKey, roleLoader);
|
|
18
18
|
const rbac = new Rbac(authUser, role);
|
|
19
19
|
request.rbac = rbac;
|
|
20
|
+
reply.rbac = rbac;
|
|
20
21
|
}
|
|
21
22
|
else {
|
|
22
23
|
const rbac = new Rbac(null, null);
|
|
23
24
|
request.rbac = rbac;
|
|
25
|
+
reply.rbac = rbac;
|
|
24
26
|
}
|
|
25
27
|
return;
|
|
26
28
|
}
|
|
@@ -50,7 +50,7 @@ async function UserAvatarRoutes(fastify, options) {
|
|
|
50
50
|
const filename = request.params.filename;
|
|
51
51
|
const subPath = 'avatar';
|
|
52
52
|
const fileDir = join(BASE_FILE_DIR, subPath);
|
|
53
|
-
console.log("FILE_DIR: ", fileDir, " FILENAME:", filename);
|
|
53
|
+
//console.log("FILE_DIR: ", fileDir, " FILENAME:", filename);
|
|
54
54
|
return reply.sendFile(filename, fileDir);
|
|
55
55
|
}
|
|
56
56
|
catch (e) {
|
|
@@ -9,7 +9,6 @@ class UserApiKeyService extends AbstractService {
|
|
|
9
9
|
constructor(userApiKeyRepostitory) {
|
|
10
10
|
super(userApiKeyRepostitory, UserApiKeyBaseSchema);
|
|
11
11
|
this._repository = userApiKeyRepostitory;
|
|
12
|
-
console.log("UserApiKeyService constructor");
|
|
13
12
|
}
|
|
14
13
|
async create(userApiKeyData) {
|
|
15
14
|
try {
|
|
@@ -11,7 +11,6 @@ class UserService extends AbstractService {
|
|
|
11
11
|
constructor(userRepository) {
|
|
12
12
|
super(userRepository, UserBaseSchema);
|
|
13
13
|
this._repository = userRepository;
|
|
14
|
-
console.log("UserService constructor");
|
|
15
14
|
}
|
|
16
15
|
async auth(username, password, { userAgent, ip }) {
|
|
17
16
|
let user = null;
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.43.0",
|
|
7
7
|
"description": "Identity module for user management, authentication and authorization.",
|
|
8
8
|
"main": "dist/index.js",
|
|
9
9
|
"types": "types/index.d.ts",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"author": "Cristian Incarnato & Drax Team",
|
|
29
29
|
"license": "ISC",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@drax/common-back": "^0.
|
|
32
|
-
"@drax/crud-back": "^0.
|
|
33
|
-
"@drax/crud-share": "^0.
|
|
34
|
-
"@drax/email-back": "^0.
|
|
35
|
-
"@drax/identity-share": "^0.
|
|
31
|
+
"@drax/common-back": "^0.43.0",
|
|
32
|
+
"@drax/crud-back": "^0.43.0",
|
|
33
|
+
"@drax/crud-share": "^0.43.0",
|
|
34
|
+
"@drax/email-back": "^0.43.0",
|
|
35
|
+
"@drax/identity-share": "^0.43.0",
|
|
36
36
|
"bcryptjs": "^2.4.3",
|
|
37
37
|
"graphql": "^16.8.2",
|
|
38
38
|
"jsonwebtoken": "^9.0.2"
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"debug": "0"
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "3451a1c66eaf3facd4fef67d96750bf5d38a1d5c"
|
|
67
67
|
}
|
|
@@ -141,15 +141,9 @@ class UserController extends AbstractFastifyController<IUser, IUserCreate, IUser
|
|
|
141
141
|
|
|
142
142
|
if (request.authUser && request.token) {
|
|
143
143
|
const tenantId = request.body.tenantId
|
|
144
|
-
if (!tenantId) {
|
|
145
|
-
throw new BadRequestError('Missing tenantId')
|
|
146
|
-
}
|
|
147
144
|
|
|
148
|
-
const tenant = await TenantServiceFactory().findById(tenantId);
|
|
149
145
|
|
|
150
|
-
|
|
151
|
-
throw new BadRequestError('Invalid tenantId')
|
|
152
|
-
}
|
|
146
|
+
const tenant = tenantId ? await TenantServiceFactory().findById(tenantId) : undefined;
|
|
153
147
|
|
|
154
148
|
const tenantName = tenant?.name;
|
|
155
149
|
const userService = UserServiceFactory()
|
|
@@ -22,9 +22,11 @@ async function rbacMiddleware (request, reply) {
|
|
|
22
22
|
const role : IRole = await draxCache.getOrLoad(cacheKey, roleLoader)
|
|
23
23
|
const rbac: IRbac = new Rbac(authUser,role)
|
|
24
24
|
request.rbac = rbac
|
|
25
|
+
reply.rbac = rbac
|
|
25
26
|
}else{
|
|
26
27
|
const rbac: IRbac = new Rbac(null,null)
|
|
27
28
|
request.rbac = rbac
|
|
29
|
+
reply.rbac = rbac
|
|
28
30
|
}
|
|
29
31
|
return
|
|
30
32
|
}catch (e) {
|
|
@@ -13,7 +13,6 @@ class RoleService extends AbstractService<IRole, IRoleBase, IRoleBase> {
|
|
|
13
13
|
constructor(roleRepostitory: IRoleRepository) {
|
|
14
14
|
super(roleRepostitory, RoleBaseSchema)
|
|
15
15
|
this._repository = roleRepostitory
|
|
16
|
-
console.log("RoleService constructor")
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
async create(roleData: IRoleBase): Promise<IRole> {
|
|
@@ -13,7 +13,6 @@ class TenantService extends AbstractService<ITenant,ITenantBase,ITenantBase> {
|
|
|
13
13
|
constructor(tenantRepostitory: ITenantRepository) {
|
|
14
14
|
super(tenantRepostitory, TenantBaseSchema)
|
|
15
15
|
this._repository = tenantRepostitory
|
|
16
|
-
console.log("TenantService constructor")
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
async create(tenantData: ITenantBase): Promise<ITenant> {
|
|
@@ -16,7 +16,6 @@ class UserApiKeyService extends AbstractService<IUserApiKey, IUserApiKeyBase, IU
|
|
|
16
16
|
constructor(userApiKeyRepostitory: IUserApiKeyRepository) {
|
|
17
17
|
super(userApiKeyRepostitory,UserApiKeyBaseSchema)
|
|
18
18
|
this._repository = userApiKeyRepostitory
|
|
19
|
-
console.log("UserApiKeyService constructor")
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
async create(userApiKeyData: IUserApiKeyBase): Promise<IUserApiKey> {
|
|
@@ -19,7 +19,6 @@ class UserService extends AbstractService<IUser, IUserCreate, IUserUpdate> {
|
|
|
19
19
|
constructor(userRepository: IUserRepository) {
|
|
20
20
|
super(userRepository, UserBaseSchema);
|
|
21
21
|
this._repository = userRepository;
|
|
22
|
-
console.log("UserService constructor")
|
|
23
22
|
}
|
|
24
23
|
|
|
25
24
|
async auth(username: string, password: string, {userAgent, ip}) {
|
|
@@ -18,7 +18,6 @@ async function CreateOrUpdateRole(roleData: IRoleBase):Promise<IRole> {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
if(role){
|
|
21
|
-
console.log("RoleData",roleData)
|
|
22
21
|
const r = await roleService.systemUpdate(role._id.toString(), roleData)
|
|
23
22
|
console.log("Role Updated. Name: "+ roleData.name)
|
|
24
23
|
return r
|