@@ -3,13 +3,12 @@ import path from 'path';
33import fs from 'fs' ;
44import { Express } from 'express' ;
55import fetch from 'node-fetch' ;
6- import { AdminUserAuthorizeFunction , IAdminForth , IExpressHttpServer , HttpExtra } from '../types/Back.js' ;
6+ import { IAdminForth , IExpressHttpServer } from '../types/Back.js' ;
77import { WebSocketServer } from 'ws' ;
88import { WebSocketClient } from './common.js' ;
99import { AdminUser } from '../types/Common.js' ;
1010import http from 'http' ;
1111import { randomUUID } from 'crypto' ;
12- import { listify } from '../modules/utils.js' ;
1312
1413function replaceAtStart ( string , substring ) {
1514 if ( string . startsWith ( substring ) ) {
@@ -217,25 +216,6 @@ class ExpressServer implements IExpressHttpServer {
217216 this . server . listen ( ...args ) ;
218217 }
219218
220- async processAuthorizeCallbacks ( adminUser : AdminUser , toReturn : { error ?: string , allowed : boolean } , response : Response , extra : any ) {
221- const adminUserAuthorize = this . adminforth . config . auth . adminUserAuthorize as ( AdminUserAuthorizeFunction [ ] | undefined ) ;
222-
223- for ( const hook of listify ( adminUserAuthorize ) ) {
224- const resp = await hook ( {
225- adminUser,
226- response,
227- adminforth : this . adminforth ,
228- extra,
229- } ) ;
230- if ( resp ?. allowed === false || resp ?. error ) {
231- // delete all items from toReturn and add these:
232- toReturn . allowed = resp ?. allowed ;
233- toReturn . error = resp ?. error ;
234- break ;
235- }
236- }
237- }
238-
239219
240220 authorize ( handler ) {
241221 return async ( req , res , next ) => {
@@ -268,13 +248,7 @@ class ExpressServer implements IExpressHttpServer {
268248 res . status ( 401 ) . send ( 'Unauthorized by AdminForth' ) ;
269249 } else {
270250 req . adminUser = adminforthUser ;
271- const toReturn : { error ?: string , allowed : boolean } = { allowed : true } ;
272- await this . processAuthorizeCallbacks ( adminforthUser , toReturn , res , { } ) ;
273- if ( ! toReturn . allowed ) {
274- res . status ( 401 ) . send ( 'Unauthorized by AdminForth' ) ;
275- } else {
276- handler ( req , res , next ) ;
277- }
251+ handler ( req , res , next ) ;
278252 }
279253 } ;
280254 }
0 commit comments