@drax/identity-back 0.42.2 → 0.44.1
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/repository/mongo/UserSessionMongoRepository.js +1 -1
- package/dist/repository/sqlite/RoleSqliteRepository.js +2 -0
- package/dist/repository/sqlite/UserLoginFailSqliteRepository.js +3 -3
- package/dist/repository/sqlite/UserSessionSqliteRepository.js +1 -1
- package/package.json +7 -7
- package/src/controllers/UserController.ts +1 -7
- package/src/repository/mongo/UserSessionMongoRepository.ts +1 -1
- package/src/repository/sqlite/RoleSqliteRepository.ts +2 -0
- package/src/repository/sqlite/UserLoginFailSqliteRepository.ts +3 -3
- package/src/repository/sqlite/UserSessionSqliteRepository.ts +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/types/controllers/UserController.d.ts.map +1 -1
- package/types/repository/sqlite/RoleSqliteRepository.d.ts.map +1 -1
- package/types/repository/sqlite/UserLoginFailSqliteRepository.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);
|
|
@@ -4,7 +4,7 @@ class UserSessionMongoRepository extends AbstractMongoRepository {
|
|
|
4
4
|
constructor() {
|
|
5
5
|
super();
|
|
6
6
|
this._model = UserSessionModel;
|
|
7
|
-
this._searchFields = ['uuid', '
|
|
7
|
+
this._searchFields = ['uuid', 'userAgent', 'ip'];
|
|
8
8
|
this._populateFields = ['user'];
|
|
9
9
|
}
|
|
10
10
|
}
|
|
@@ -12,6 +12,8 @@ class RoleSqliteRepository extends AbstractSqliteRepository {
|
|
|
12
12
|
{ name: "permissions", type: "TEXT", unique: false, primary: false },
|
|
13
13
|
{ name: "childRoles", type: "TEXT", unique: false, primary: false },
|
|
14
14
|
{ name: "readonly", type: "INTEGER", unique: false, primary: false },
|
|
15
|
+
{ name: "icon", type: "TEXT", unique: false, primary: false },
|
|
16
|
+
{ name: "color", type: "TEXT", unique: false, primary: false },
|
|
15
17
|
{ name: "createdAt", type: "TEXT", unique: false, primary: false },
|
|
16
18
|
{ name: "updatedAt", type: "TEXT", unique: false, primary: false },
|
|
17
19
|
];
|
|
@@ -2,15 +2,15 @@ import { AbstractSqliteRepository } from "@drax/crud-back";
|
|
|
2
2
|
class UserLoginFailSqliteRepository extends AbstractSqliteRepository {
|
|
3
3
|
constructor() {
|
|
4
4
|
super(...arguments);
|
|
5
|
-
this.tableName = '
|
|
5
|
+
this.tableName = 'user_login_fails';
|
|
6
6
|
this.searchFields = [];
|
|
7
7
|
this.booleanFields = [];
|
|
8
8
|
this.identifier = '_id';
|
|
9
9
|
this.populateFields = [{ field: 'user', table: 'users', identifier: '_id' }];
|
|
10
10
|
this.tableFields = [
|
|
11
11
|
{ name: "uuid", type: "TEXT", unique: false, primary: false },
|
|
12
|
-
{ name: "
|
|
13
|
-
{ name: "
|
|
12
|
+
{ name: "username", type: "TEXT", unique: false, primary: false },
|
|
13
|
+
{ name: "userAgent", type: "TEXT", unique: false, primary: false },
|
|
14
14
|
{ name: "ip", type: "TEXT", unique: false, primary: false },
|
|
15
15
|
{ name: "createdAt", type: "TEXT", unique: false, primary: false },
|
|
16
16
|
{ name: "updatedAt", type: "TEXT", unique: false, primary: false },
|
|
@@ -10,7 +10,7 @@ class UserSessionSqliteRepository extends AbstractSqliteRepository {
|
|
|
10
10
|
this.tableFields = [
|
|
11
11
|
{ name: "uuid", type: "TEXT", unique: false, primary: false },
|
|
12
12
|
{ name: "user", type: "TEXT", unique: false, primary: false },
|
|
13
|
-
{ name: "
|
|
13
|
+
{ name: "userAgent", type: "TEXT", unique: false, primary: false },
|
|
14
14
|
{ name: "ip", type: "TEXT", unique: false, primary: false },
|
|
15
15
|
{ name: "createdAt", type: "TEXT", unique: false, primary: false },
|
|
16
16
|
{ name: "updatedAt", type: "TEXT", unique: false, primary: false },
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.44.1",
|
|
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.44.1",
|
|
32
|
+
"@drax/crud-back": "^0.44.1",
|
|
33
|
+
"@drax/crud-share": "^0.44.1",
|
|
34
|
+
"@drax/email-back": "^0.44.1",
|
|
35
|
+
"@drax/identity-share": "^0.44.1",
|
|
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": "f80d56ce3769fe36bf69f1903efa0a4290de06a2"
|
|
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()
|
|
@@ -10,7 +10,7 @@ class UserSessionMongoRepository extends AbstractMongoRepository<IUserSession, I
|
|
|
10
10
|
constructor() {
|
|
11
11
|
super();
|
|
12
12
|
this._model = UserSessionModel;
|
|
13
|
-
this._searchFields = ['uuid', '
|
|
13
|
+
this._searchFields = ['uuid', 'userAgent', 'ip'];
|
|
14
14
|
this._populateFields = ['user'];
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -21,6 +21,8 @@ class RoleSqliteRepository extends AbstractSqliteRepository<IRole, IRoleBase, IR
|
|
|
21
21
|
{name: "permissions", type: "TEXT", unique: false, primary: false},
|
|
22
22
|
{name: "childRoles", type: "TEXT", unique: false, primary: false},
|
|
23
23
|
{name: "readonly", type: "INTEGER", unique: false, primary: false},
|
|
24
|
+
{name: "icon", type: "TEXT", unique: false, primary: false},
|
|
25
|
+
{name: "color", type: "TEXT", unique: false, primary: false},
|
|
24
26
|
{name: "createdAt", type: "TEXT", unique: false, primary: false},
|
|
25
27
|
{name: "updatedAt", type: "TEXT", unique: false, primary: false},
|
|
26
28
|
]
|
|
@@ -7,7 +7,7 @@ import UserSqliteRepository from "./UserSqliteRepository.js";
|
|
|
7
7
|
class UserLoginFailSqliteRepository extends AbstractSqliteRepository<IUserLoginFail,IUserLoginFailBase,IUserLoginFailBase> implements IUserLoginFailRepository{
|
|
8
8
|
|
|
9
9
|
protected db: any;
|
|
10
|
-
protected tableName: string = '
|
|
10
|
+
protected tableName: string = 'user_login_fails';
|
|
11
11
|
protected dataBaseFile: string;
|
|
12
12
|
protected searchFields: string[] = [];
|
|
13
13
|
protected booleanFields: string[] = [];
|
|
@@ -15,8 +15,8 @@ class UserLoginFailSqliteRepository extends AbstractSqliteRepository<IUserLoginF
|
|
|
15
15
|
protected populateFields = [{field: 'user', table: 'users', identifier: '_id'}]
|
|
16
16
|
protected tableFields: SqliteTableField[] = [
|
|
17
17
|
{name: "uuid", type: "TEXT", unique: false, primary: false},
|
|
18
|
-
{name: "
|
|
19
|
-
{name: "
|
|
18
|
+
{name: "username", type: "TEXT", unique: false, primary: false},
|
|
19
|
+
{name: "userAgent", type: "TEXT", unique: false, primary: false},
|
|
20
20
|
{name: "ip", type: "TEXT", unique: false, primary: false},
|
|
21
21
|
{name: "createdAt", type: "TEXT", unique: false, primary: false},
|
|
22
22
|
{name: "updatedAt", type: "TEXT", unique: false, primary: false},
|
|
@@ -17,7 +17,7 @@ class UserSessionSqliteRepository extends AbstractSqliteRepository<IUserSession,
|
|
|
17
17
|
protected tableFields: SqliteTableField[] = [
|
|
18
18
|
{name: "uuid", type: "TEXT", unique: false, primary: false},
|
|
19
19
|
{name: "user", type: "TEXT", unique: false, primary: false},
|
|
20
|
-
{name: "
|
|
20
|
+
{name: "userAgent", type: "TEXT", unique: false, primary: false},
|
|
21
21
|
{name: "ip", type: "TEXT", unique: false, primary: false},
|
|
22
22
|
{name: "createdAt", type: "TEXT", unique: false, primary: false},
|
|
23
23
|
{name: "updatedAt", type: "TEXT", unique: false, primary: false},
|