@cloudron/tegel 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +7 -3
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -9,7 +9,9 @@ export async function createExpressApp({ sessionSecret = 'changeme', oidcConfig
9
9
 
10
10
  const app = express();
11
11
 
12
- app.set('trust proxy', 1);
12
+ app.set('trust proxy', true);
13
+ app.set('json spaces', 2);
14
+ app.set('query parser', 'simple');
13
15
 
14
16
  app.use(express.json());
15
17
 
@@ -113,8 +115,8 @@ export function logout(redirectTo) {
113
115
  };
114
116
  }
115
117
 
116
- export function requireAuth(redirectTo) {
117
- if (!redirectTo || typeof redirectTo !== 'string') throw new Error('requireAuth needs a redirectTo path as non-empty string');
118
+ export function requireAuth(redirectTo = '') {
119
+ if (typeof redirectTo !== 'string') throw new Error('requireAuth needs a redirectTo path as non-empty string');
118
120
 
119
121
  return (req, res, next) => {
120
122
  if (req.session && req.session.user) {
@@ -122,6 +124,8 @@ export function requireAuth(redirectTo) {
122
124
  return next();
123
125
  }
124
126
 
127
+ if (!redirectTo) return next(new HttpError(401, 'Unauthorized'));
128
+
125
129
  res.redirect(redirectTo);
126
130
  };
127
131
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudron/tegel",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "",
5
5
  "license": "GPL-2.0",
6
6
  "author": "Cloudron Developers",
@@ -20,6 +20,6 @@
20
20
  "devDependencies": {
21
21
  "@eslint/js": "^9.39.2",
22
22
  "eslint": "^9.39.2",
23
- "globals": "^17.1.0"
23
+ "globals": "^17.3.0"
24
24
  }
25
25
  }