Switching to ws instead of socket.io and implementing basic authentication
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import Session from "./session";
|
||||
import Logging from "@hibas123/nodelogging";
|
||||
|
||||
interface IRule<T> {
|
||||
".write"?: T
|
||||
@ -64,7 +65,27 @@ export class Rules {
|
||||
let rules = this.rules;
|
||||
|
||||
for (let segment of path) {
|
||||
rules = rules[segment] || rules["*"];
|
||||
if (segment.startsWith("$") || segment.startsWith(".")) {
|
||||
read = false;
|
||||
write = false;
|
||||
Logging.log("Invalid query path (started with '$' or '.'):", path);
|
||||
break;
|
||||
}
|
||||
|
||||
let k = Object.keys(rules)
|
||||
.filter(e => e.startsWith("$"))
|
||||
.find(e => {
|
||||
switch (e) {
|
||||
case "$uid":
|
||||
if (segment === session.uid)
|
||||
return true;
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
})
|
||||
|
||||
rules = (k ? rules[k] : undefined) || rules[segment] || rules["*"];
|
||||
|
||||
if (rules) {
|
||||
if (rules[".read"]) {
|
||||
read = rules[".read"]
|
||||
|
Reference in New Issue
Block a user