Fixed database abstraction naming and changed a lot of lets to consts and /unauth/permanote is broken

This commit is contained in:
Ben
2018-11-07 15:13:57 +00:00
parent 7ab179208e
commit 7aead446de
22 changed files with 112 additions and 126 deletions

View File

@@ -1,19 +1,19 @@
import {MiddleWare} from './index';
import {API} from '../api/api';
import {Logger} from '../../models/logger'
import {AuthModel} from '../../models/auth/authModel';
import {Auth} from '../../models/auth/authModel';
export class AuthMiddleWare extends MiddleWare {
static async authUser(req, res, next) {
let errors = new API.errors(res);
const errors = new API.errors(res);
if (!req.headers.authorization) {
errors.addError(403, 'Forbidden', 'You cannot access this resource without authorization').endpoint();
return;
}
let token = req.headers.authorization;
let user = await AuthModel.getUserFromToken(token);
const token = req.headers.authorization;
const user = await Auth.getUserFromToken(token);
if (user == -1) {
errors.addError(403, 'Forbidden', 'You cannot access this resource without authorization').endpoint();
return;

View File

@@ -1,6 +1,6 @@
export class ErrorHandler {
static async newError(err, req, res, next) {
}
}

View File

@@ -7,7 +7,7 @@ let buckets = {}
export class RateLimits extends MiddleWare {
static async request(req, res, next) {
let ip = req.connection.remoteAddress;
const ip = req.connection.remoteAddress;
MiddleWare.analytics(req, res, next);
if (!buckets[ip]) {