Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit 3617d26

Browse files
Fix setting update channel (#124)
Co-authored-by: William Connatser <[email protected]>
1 parent 3205e4c commit 3617d26

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

middlewares/auth.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import {Buffer} from 'node:buffer';
2-
import {STATUS_CODES} from '@runcitadel/utils';
2+
import {STATUS_CODES, typeHelper} from '@runcitadel/utils';
33
import * as passportJWT from 'passport-jwt';
44
import * as passportHTTP from 'passport-http';
55
import * as bcrypt from '@node-rs/bcrypt';
@@ -138,6 +138,7 @@ export async function basic(ctx: Context, next: Next): Promise<void> {
138138

139139
// Check 2FA token when enabled
140140
if (userInfo.settings?.twoFactorAuth) {
141+
typeHelper.isString(ctx.request.body.totpToken, ctx);
141142
const vres = notp.totp.verify(
142143
ctx.request.body.totpToken,
143144
userInfo.settings.twoFactorKey || '',

routes/v1/account.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ router.post('/totp/enable', auth.jwt, async (ctx) => {
170170
// TOTP should be already set up
171171
const key = info.settings?.twoFactorKey;
172172

173+
typeHelper.isString(ctx.request.body.authenticatorToken, ctx);
173174
const vres = notp.totp.verify(ctx.request.body.authenticatorToken, key);
174175

175176
if (vres && vres.delta === 0) {
@@ -190,6 +191,7 @@ router.post('/totp/disable', auth.jwt, async (ctx, next) => {
190191
// TOTP should be already set up
191192
const key = info.settings?.twoFactorKey;
192193

194+
typeHelper.isString(ctx.request.body.authenticatorToken, ctx);
193195
const vres = notp.totp.verify(ctx.request.body.authenticatorToken, key);
194196

195197
if (vres && vres.delta === 0) {

routes/v2/system.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,9 @@ router.get('/disk-type', auth.jwt, async (ctx, next) => {
150150
});
151151

152152
router.put('/update-channel', auth.jwt, async (ctx, next) => {
153-
typeHelper.isString(ctx.body.channel, ctx);
154-
await systemLogic.setUpdateChannel(ctx.body.channel as string);
153+
typeHelper.isString(ctx.request.body.channel, ctx);
154+
await systemLogic.setUpdateChannel(ctx.request.body.channel as string);
155+
ctx.body = {};
155156
await next();
156157
});
157158

0 commit comments

Comments
 (0)