youzanyun-devtool-worker
Version:
- web - ws - proxy
30 lines (29 loc) • 835 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const ignoreAuth = [
'/api/common/appServer/heartbeat',
'/api/common/appServer/exit',
'/api/common/getIp',
'/api/third-login/info',
'/html/login',
];
function default_1({ container }) {
return async function auth(ctx, next) {
let userService = await container.getServiceInstance("userService");
let sid = await userService.getSid();
let { path, originalUrl } = ctx;
if (!((path.startsWith('/html') || path.startsWith('/api')) && ignoreAuth.indexOf(path) === -1)) {
await next();
return;
}
if (sid) {
await next();
}
else {
ctx.redirect('/html/login');
return;
}
};
}
exports.default = default_1;
;