@cocreate/authorize 1.7.2 → 1.7.4
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/CHANGELOG.md +14 -0
- package/package.json +2 -2
- package/src/index.js +12 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.7.4](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.7.3...v1.7.4) (2023-10-16)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* improved error handling ([05dd30f](https://github.com/CoCreate-app/CoCreate-authorize/commit/05dd30faa849090707d2b65c724441e071ee5fff))
|
|
7
|
+
|
|
8
|
+
## [1.7.3](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.7.2...v1.7.3) (2023-10-14)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* bump dependencies ([8ef2dc2](https://github.com/CoCreate-app/CoCreate-authorize/commit/8ef2dc28d6f633e182f5aa3d0b395996ce5e9c78))
|
|
14
|
+
|
|
1
15
|
## [1.7.2](https://github.com/CoCreate-app/CoCreate-authorize/compare/v1.7.1...v1.7.2) (2023-10-09)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cocreate/authorize",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.4",
|
|
4
4
|
"description": "A simple authorize component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authorize",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"main": "./src/index.js",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@cocreate/crud-client": "^1.28.
|
|
48
|
+
"@cocreate/crud-client": "^1.28.1",
|
|
49
49
|
"@cocreate/utils": "^1.25.0"
|
|
50
50
|
}
|
|
51
51
|
}
|
package/src/index.js
CHANGED
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
async function readAuthorization(key, organization_id) {
|
|
92
92
|
try {
|
|
93
93
|
if (!organization_id)
|
|
94
|
-
return
|
|
94
|
+
return { error: 'An organization_id is required' };
|
|
95
95
|
|
|
96
96
|
let request = {
|
|
97
97
|
method: 'read.object',
|
|
@@ -141,7 +141,7 @@
|
|
|
141
141
|
|
|
142
142
|
} catch (error) {
|
|
143
143
|
console.log("authorization Error", error)
|
|
144
|
-
return
|
|
144
|
+
return { error };
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
}
|
|
@@ -201,22 +201,23 @@
|
|
|
201
201
|
async function checkAuthorization({ key, data }) {
|
|
202
202
|
// let method = data.method
|
|
203
203
|
let { method, organization_id, endPoint } = data
|
|
204
|
-
if (!
|
|
204
|
+
if (!organization_id)
|
|
205
|
+
return { error: '' };
|
|
205
206
|
|
|
206
|
-
let
|
|
207
|
-
if (!
|
|
208
|
-
return
|
|
209
|
-
if (
|
|
207
|
+
let authorized = await getAuthorization(key, organization_id)
|
|
208
|
+
if (!authorized || authorized.error)
|
|
209
|
+
return authorized
|
|
210
|
+
if (authorized.organization_id !== organization_id)
|
|
210
211
|
return false;
|
|
211
|
-
if (
|
|
212
|
-
if (!
|
|
212
|
+
if (authorized.host && authorized.host.length) {
|
|
213
|
+
if (!authorized.host || (!authorized.host.includes(data.host) && !authorized.host.includes("*")))
|
|
213
214
|
return false;
|
|
214
215
|
|
|
215
216
|
}
|
|
216
|
-
if (
|
|
217
|
+
if (authorized.admin == 'true' || authorized.admin === true)
|
|
217
218
|
return true;
|
|
218
219
|
|
|
219
|
-
let status = await checkMethod(
|
|
220
|
+
let status = await checkMethod(authorized.actions, method, endPoint, data)
|
|
220
221
|
|
|
221
222
|
if (!status)
|
|
222
223
|
return false
|