@adminforth/user-soft-delete 1.0.0 → 1.1.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/index.js +11 -3
- package/index.ts +14 -2
- package/package.json +4 -4
- package/types.ts +1 -1
package/dist/index.js
CHANGED
|
@@ -48,6 +48,17 @@ export default class UserSoftDelete extends AdminForthPlugin {
|
|
|
48
48
|
return rejectResult;
|
|
49
49
|
}
|
|
50
50
|
}));
|
|
51
|
+
const adminUserAuthorize = this.adminforth.config.auth.adminUserAuthorize;
|
|
52
|
+
const adminUserAuthorizeArray = Array.isArray(adminUserAuthorize) ? adminUserAuthorize : [adminUserAuthorize];
|
|
53
|
+
adminUserAuthorizeArray.unshift((_a) => __awaiter(this, [_a], void 0, function* ({ extra, adminUser }) {
|
|
54
|
+
const rejectResult = {
|
|
55
|
+
error: 'Your account is deactivated',
|
|
56
|
+
allowed: false,
|
|
57
|
+
};
|
|
58
|
+
if (adminUser.dbUser[this.options.activeFieldName] === false) {
|
|
59
|
+
return rejectResult;
|
|
60
|
+
}
|
|
61
|
+
}));
|
|
51
62
|
if (!resourceConfig.options.pageInjections) {
|
|
52
63
|
resourceConfig.options.pageInjections = {};
|
|
53
64
|
}
|
|
@@ -88,9 +99,6 @@ export default class UserSoftDelete extends AdminForthPlugin {
|
|
|
88
99
|
if (typeof this.allowDisableFunc === "function") {
|
|
89
100
|
isAllowedToDeactivate = yield this.allowDisableFunc(adminUser);
|
|
90
101
|
}
|
|
91
|
-
else if (typeof this.allowDisableFunc === "boolean") {
|
|
92
|
-
isAllowedToDeactivate = this.allowDisableFunc;
|
|
93
|
-
}
|
|
94
102
|
if (isAllowedToDeactivate === false) {
|
|
95
103
|
return { ok: false, error: "Not allowed to deactivate user" };
|
|
96
104
|
}
|
package/index.ts
CHANGED
|
@@ -44,6 +44,20 @@ export default class UserSoftDelete extends AdminForthPlugin {
|
|
|
44
44
|
}
|
|
45
45
|
);
|
|
46
46
|
|
|
47
|
+
const adminUserAuthorize = this.adminforth.config.auth.adminUserAuthorize;
|
|
48
|
+
const adminUserAuthorizeArray = Array.isArray(adminUserAuthorize) ? adminUserAuthorize : [adminUserAuthorize];
|
|
49
|
+
adminUserAuthorizeArray.unshift(
|
|
50
|
+
async({ extra, adminUser }: { adminUser: AdminUser, response: IAdminForthHttpResponse, extra?: any} )=> {
|
|
51
|
+
const rejectResult = {
|
|
52
|
+
error: 'Your account is deactivated',
|
|
53
|
+
allowed: false,
|
|
54
|
+
};
|
|
55
|
+
if (adminUser.dbUser[this.options.activeFieldName] === false) {
|
|
56
|
+
return rejectResult;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
|
|
47
61
|
if ( !resourceConfig.options.pageInjections ) {
|
|
48
62
|
resourceConfig.options.pageInjections = {};
|
|
49
63
|
}
|
|
@@ -88,8 +102,6 @@ export default class UserSoftDelete extends AdminForthPlugin {
|
|
|
88
102
|
let isAllowedToDeactivate = false;
|
|
89
103
|
if ( typeof this.allowDisableFunc === "function" ) {
|
|
90
104
|
isAllowedToDeactivate = await this.allowDisableFunc(adminUser);
|
|
91
|
-
} else if (typeof this.allowDisableFunc === "boolean") {
|
|
92
|
-
isAllowedToDeactivate = this.allowDisableFunc;
|
|
93
105
|
}
|
|
94
106
|
if ( isAllowedToDeactivate === false ) {
|
|
95
107
|
return {ok: false, error: "Not allowed to deactivate user"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/user-soft-delete",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"description": "",
|
|
17
17
|
"devDependencies": {
|
|
18
18
|
"@types/node": "latest",
|
|
19
|
-
"typescript": "^5.7.3",
|
|
20
19
|
"semantic-release": "^24.2.1",
|
|
21
|
-
"semantic-release-slack-bot": "^4.0.2"
|
|
20
|
+
"semantic-release-slack-bot": "^4.0.2",
|
|
21
|
+
"typescript": "^5.7.3"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"adminforth": "^2.4.0-next.
|
|
24
|
+
"adminforth": "^2.4.0-next.227"
|
|
25
25
|
},
|
|
26
26
|
"release": {
|
|
27
27
|
"plugins": [
|
package/types.ts
CHANGED