forked from hippoz/brainlet
add _id field for messages and allow authorization header for rest api requests
This commit is contained in:
parent
78d3071a84
commit
11f93542c3
3 changed files with 4 additions and 4 deletions
|
@ -91,7 +91,8 @@ class GatewayServer extends EventEmitter {
|
||||||
author: {
|
author: {
|
||||||
_id: ws.session.user._id,
|
_id: ws.session.user._id,
|
||||||
username: ws.session.user.username
|
username: ws.session.user.username
|
||||||
}
|
},
|
||||||
|
_id: uuid.v4()
|
||||||
}));
|
}));
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -35,7 +35,7 @@ const checkToken = (token, minPermissionLevel=config.roleMap.RESTRICTED) => {
|
||||||
|
|
||||||
function authenticateEndpoint(callback, url=undefined, minPermissionLevel=config.roleMap.RESTRICTED) {
|
function authenticateEndpoint(callback, url=undefined, minPermissionLevel=config.roleMap.RESTRICTED) {
|
||||||
return (req, res) => {
|
return (req, res) => {
|
||||||
const token = req.cookies.token;
|
const token = req.headers.authorization || req.cookies.token;
|
||||||
if (!token) return redirect(res, 403, url);
|
if (!token) return redirect(res, 403, url);
|
||||||
checkToken(token, minPermissionLevel).then((user) => {
|
checkToken(token, minPermissionLevel).then((user) => {
|
||||||
if (!user) return redirect(res, 403, url);
|
if (!user) return redirect(res, 403, url);
|
||||||
|
|
|
@ -23,8 +23,6 @@ Packets can also have JSON as a payload:
|
||||||
|
|
||||||
## Instructions
|
## Instructions
|
||||||
|
|
||||||
The terms "channel" and "channel" are used interchangeably.
|
|
||||||
|
|
||||||
## 0:HELLO
|
## 0:HELLO
|
||||||
*Part of handshake, Server to client*
|
*Part of handshake, Server to client*
|
||||||
|
|
||||||
|
@ -177,6 +175,7 @@ JSON data format:
|
||||||
| content | The text content of the message (max 2000 characters, min 1 character, trimmed) |
|
| content | The text content of the message (max 2000 characters, min 1 character, trimmed) |
|
||||||
| channel | A [message channel object](#message-channel-object) |
|
| channel | A [message channel object](#message-channel-object) |
|
||||||
| author | A [message author object](#message-author-object) |
|
| author | A [message author object](#message-author-object) |
|
||||||
|
| _id | A UUIDv4 |
|
||||||
|
|
||||||
## Message channel object
|
## Message channel object
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue