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

Commit

Permalink
Fix setting update channel (#124)
Browse files Browse the repository at this point in the history
Co-authored-by: William Connatser <[email protected]>
  • Loading branch information
AaronDewes and WilliamConnatser authored Jun 26, 2022
1 parent 3205e4c commit 3617d26
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion middlewares/auth.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Buffer} from 'node:buffer';
import {STATUS_CODES} from '@runcitadel/utils';
import {STATUS_CODES, typeHelper} from '@runcitadel/utils';
import * as passportJWT from 'passport-jwt';
import * as passportHTTP from 'passport-http';
import * as bcrypt from '@node-rs/bcrypt';
Expand Down Expand Up @@ -138,6 +138,7 @@ export async function basic(ctx: Context, next: Next): Promise<void> {

// Check 2FA token when enabled
if (userInfo.settings?.twoFactorAuth) {
typeHelper.isString(ctx.request.body.totpToken, ctx);
const vres = notp.totp.verify(
ctx.request.body.totpToken,
userInfo.settings.twoFactorKey || '',
Expand Down
2 changes: 2 additions & 0 deletions routes/v1/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ router.post('/totp/enable', auth.jwt, async (ctx) => {
// TOTP should be already set up
const key = info.settings?.twoFactorKey;

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

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

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

if (vres && vres.delta === 0) {
Expand Down
5 changes: 3 additions & 2 deletions routes/v2/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,9 @@ router.get('/disk-type', auth.jwt, async (ctx, next) => {
});

router.put('/update-channel', auth.jwt, async (ctx, next) => {
typeHelper.isString(ctx.body.channel, ctx);
await systemLogic.setUpdateChannel(ctx.body.channel as string);
typeHelper.isString(ctx.request.body.channel, ctx);
await systemLogic.setUpdateChannel(ctx.request.body.channel as string);
ctx.body = {};
await next();
});

Expand Down

0 comments on commit 3617d26

Please sign in to comment.