corebasic 1.0.152 → 1.0.154
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/libs/messaging.js +13 -0
- package/libs/session.js +7 -2
- package/package.json +1 -1
package/libs/messaging.js
CHANGED
|
@@ -114,6 +114,19 @@ export async function produce(channel, message) {
|
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
|
|
117
|
+
|
|
118
|
+
export async function set(key, value) {
|
|
119
|
+
await defaultConsumer.set(`${process.env.REDIS_CHANNEL_PREFIX}_${key}`, typeof value === 'object' ? JSON.stringify(value) : value)
|
|
120
|
+
}
|
|
121
|
+
export async function get(key) {
|
|
122
|
+
let value = await defaultConsumer.get(`${process.env.REDIS_CHANNEL_PREFIX}_${key}`)
|
|
123
|
+
try { value = JSON.parse(value) } catch(err) { }
|
|
124
|
+
return value
|
|
125
|
+
}
|
|
126
|
+
export async function del(key) {
|
|
127
|
+
await defaultConsumer.del(`${process.env.REDIS_CHANNEL_PREFIX}_${key}`)
|
|
128
|
+
}
|
|
129
|
+
|
|
117
130
|
// Hydrate
|
|
118
131
|
|
|
119
132
|
export async function hydrate(callback) {
|
package/libs/session.js
CHANGED
|
@@ -27,7 +27,12 @@ export const start = (expressApp, allowedUrls) => {
|
|
|
27
27
|
if (urlsAllowed.includes(req.path))
|
|
28
28
|
return next()
|
|
29
29
|
|
|
30
|
-
const checkPrivilege = async req =>
|
|
30
|
+
const checkPrivilege = async req => {
|
|
31
|
+
const granted = (await Features.send({company: req.body.company, outlet: req.body.outlet}, "privileges.query.check", {feature: req.body.feature }, {id: req.body.staff})).data.granted
|
|
32
|
+
if (!granted)
|
|
33
|
+
throw {message: "Access Denied"}
|
|
34
|
+
return granted
|
|
35
|
+
}
|
|
31
36
|
|
|
32
37
|
try {
|
|
33
38
|
const token = req.header('JWT'); // 'Authorization' for Spring Boot, 'x-access-token' for Node.js Express back-end
|
|
@@ -38,7 +43,7 @@ export const start = (expressApp, allowedUrls) => {
|
|
|
38
43
|
return next()
|
|
39
44
|
throw null;
|
|
40
45
|
} catch (error) {
|
|
41
|
-
return res.status(401).json({ message: 'Unauthorized' })
|
|
46
|
+
return res.status(401).json({ message: error?.message === "Access Denied" ? error.message : 'Unauthorized' })
|
|
42
47
|
}
|
|
43
48
|
})
|
|
44
49
|
|