Fixed database abstraction naming and changed a lot of lets to consts and /unauth/permanote is broken
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
export class ErrorHandler {
|
||||
static async newError(err, req, res, next) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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]) {
|
||||
|
||||
Reference in New Issue
Block a user