Skip to content

Commit

Permalink
upd action
Browse files Browse the repository at this point in the history
  • Loading branch information
SorenEricMent committed Sep 17, 2022
1 parent 72ce151 commit 2e511c3
Show file tree
Hide file tree
Showing 205 changed files with 26,349 additions and 810 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Lint

on:
pull_request:
push:
branches:
- master

jobs:
eslint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci # or yarn install
- uses: sibiraj-s/action-eslint@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }} # Optional
eslint-args: '--ignore-path=.gitignore --quiet'
extensions: 'js,jsx,ts,tsx'
annotations: true
5 changes: 2 additions & 3 deletions modules/iapi.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ class IAPI {
this.log = log;
this.salt = salt;
this.rp = redisPrefix;
this.rateLimitFallback = siteConfig.ratelimit_fallback;
//For util functions in IAPI, redis prefix will not be automatically added.
//Redis prefix needed to be added manually in caller function.
this.log("log", "IAPI", "IAPI instance created.");
Expand Down Expand Up @@ -196,7 +195,7 @@ class IAPI {
}));
}
Promise.allSettled(promisePool).then((results) => {
let permissions = getPermissionSum(this.rateLimitFallback, results);
let permissions = getPermissionSum(results);
resolve(permissions);
}).catch((err) => {
reject(err);
Expand All @@ -209,7 +208,7 @@ class IAPI {
return new Promise((resolve, reject) => {
password = blake3Hash(this.salt + password);
this.mysql.query(
"SELECT uid,password,permissions FROM users WHERE username = ?",
"SELECT uid,password,roles FROM users WHERE username = ?",
[username],
(err, results) => {
if (err) {
Expand Down
12 changes: 11 additions & 1 deletion modules/utils.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ function pureArray(arr){
//remove all empty items in an array
return arr.filter(item => item !== "");
}

function mergeArray(...args){
return Array.from(new Set(args.reduce((a, b) => a.concat(b))));
}

function getPermissionSum(...p){
//return the greatest permissions of all given role permissions
Expand All @@ -184,7 +188,13 @@ function getPermissionSum(...p){
};
let isRateLimitContained = false;
for(const perm of p){

if(perm.with_rate_limit == 1){
if(!isRateLimitContained){
p.rate_limits = perm.rate_limits;
}
isRateLimitContained = true;
//todo: rate limit merge
}
}
return permSum;
}
Expand Down
92 changes: 51 additions & 41 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/ansi-styles/index.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 2e511c3

Please sign in to comment.