Fix auth tokens table display

This commit is contained in:
Alice Gaudon 2020-07-06 16:11:02 +02:00
parent dc78c80e29
commit 49cc9f37e4
2 changed files with 4 additions and 3 deletions

View File

@ -1,5 +1,5 @@
import Controller from "wms-core/Controller";
import {REQUIRE_AUTH_MIDDLEWARE, REQUIRE_REQUEST_AUTH_MIDDLEWARE} from "wms-core/auth/AuthComponent";
import {REQUIRE_AUTH_MIDDLEWARE} from "wms-core/auth/AuthComponent";
import {NextFunction, Request, Response} from "express";
import {BadRequestError, ForbiddenHttpError, ServerError} from "wms-core/HttpError";
import FileModel from "../models/FileModel";
@ -8,7 +8,6 @@ import * as fs from "fs";
import AuthToken from "../models/AuthToken";
import {IncomingForm} from "formidable";
import {FILE_UPLOAD_MIDDLEWARE} from "wms-core/components/ExpressAppComponent";
import Logger from "wms-core/Logger";
import generateSlug from "../SlugGenerator";
@ -25,7 +24,7 @@ export default class FileController extends Controller {
const allowedDomains = config.get<string[]>('allowed_url_domains');
res.render('file-upload', {
max_upload_size: config.get<string>('max_upload_size'),
auth_tokens: await AuthToken.select().where('user_id', req.models.user!.id!),
auth_tokens: await AuthToken.select().where('user_id', req.models.user!.id!).get(),
allowed_domains: allowedDomains,
default_domain: allowedDomains[config.get<number>('default_url_domain_for_files')],
});

View File

@ -4,6 +4,7 @@ import URLRedirect from "../models/URLRedirect";
import {REQUIRE_AUTH_MIDDLEWARE} from "wms-core/auth/AuthComponent";
import generateSlug from "../SlugGenerator";
import config from "config";
import AuthToken from "../models/AuthToken";
export default class URLRedirectController extends Controller {
routes(): void {
@ -16,6 +17,7 @@ export default class URLRedirectController extends Controller {
protected async getURLShrinker(req: Request, res: Response): Promise<void> {
const allowedDomains = config.get<string[]>('allowed_url_domains');
res.render('url-shrinker', {
auth_tokens: await AuthToken.select().where('user_id', req.models.user!.id!).get(),
allowed_domains: allowedDomains,
default_domain: allowedDomains[config.get<number>('default_url_domain_for_urls')],
});