@paralect/hive 0.0.23 → 0.0.25
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/package.json +1 -1
- package/starter/src/middlewares/isAuthorized.js +4 -0
- package/starter/src/resources/tokens/methods/storeToken.js +2 -1
- package/starter/src/resources/tokens/tokens.schema.js +1 -0
- package/starter/src/resources/users/endpoints/getCurrentUser.js +1 -3
- package/starter/src/socketIo.js +3 -1
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@ const generateSecureToken = async (tokenLength = 32) => {
|
|
|
12
12
|
return buf.toString('hex');
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
module.exports = async (ctx, { userId }) => {
|
|
15
|
+
module.exports = async (ctx, { userId, metadata = null }) => {
|
|
16
16
|
const token = await generateSecureToken();
|
|
17
17
|
const otp = await generateSecureToken();
|
|
18
18
|
|
|
@@ -22,6 +22,7 @@ module.exports = async (ctx, { userId }) => {
|
|
|
22
22
|
_id: userId,
|
|
23
23
|
},
|
|
24
24
|
otp,
|
|
25
|
+
...(metadata ? { metadata } : {})
|
|
25
26
|
});
|
|
26
27
|
|
|
27
28
|
setCookie(ctx, { name: 'access_token', value: token });
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
const Joi = require("joi");
|
|
2
|
-
const userService = require('db').services.users;
|
|
3
2
|
|
|
4
3
|
module.exports.handler = async (ctx) => {
|
|
5
|
-
|
|
6
|
-
ctx.body = user;
|
|
4
|
+
ctx.body = ctx.state.user;
|
|
7
5
|
};
|
|
8
6
|
|
|
9
7
|
module.exports.middlewares = [require('middlewares/isAuthorized')];
|
package/starter/src/socketIo.js
CHANGED
|
@@ -84,7 +84,9 @@ module.exports = (server) => {
|
|
|
84
84
|
io.on("connection", (client) => {
|
|
85
85
|
client.on("subscribe", (roomId) => {
|
|
86
86
|
const { userId } = client.handshake.data;
|
|
87
|
-
const hasAccessToRoom = checkAccessToRoom(roomId, { userId });
|
|
87
|
+
// const hasAccessToRoom = checkAccessToRoom(roomId, { userId });
|
|
88
|
+
|
|
89
|
+
const hasAccessToRoom = true;
|
|
88
90
|
|
|
89
91
|
if (hasAccessToRoom) {
|
|
90
92
|
client.join(roomId);
|