Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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