Skip to content

Commit

Permalink
Introduce backwards-compatibility for API Keys
Browse files Browse the repository at this point in the history
  • Loading branch information
lucemans committed May 29, 2022
1 parent 4004599 commit 1aeaf8f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/routes/protected/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Extract } from 'unzipper';

import { StorageBackend } from '../..';
import { DB } from '../../database';
import { useAuth } from '../../util/http/useAuth';
import { useAPIToken } from '../../util/http/useAPIToken';
import { log } from '../../util/logging';
import { startAction } from '../../util/sentry/createChild';
import { sentryHandle } from '../../util/sentry/sentryHandle';
Expand Down Expand Up @@ -59,7 +59,7 @@ export const CreateRoute: FastifyPluginAsync = async (router, options) => {
(request, reply) => {
handle(request, reply, async (transaction, registerCleanup) => {
// Check auth
const auth = await useAuth(request, reply);
const auth = await useAPIToken(request, reply);

if (typeof auth !== 'string') {
return auth;
Expand Down
2 changes: 2 additions & 0 deletions src/util/http/useAPIToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export const useAPIToken: (
owner_id: decoded.account,
});

console.log(decoded.account, decoded.value.toString());

if (!key) return { status: 403, logMessages: ['Not owner of Site'] };

request.context['user'] = {
Expand Down

0 comments on commit 1aeaf8f

Please sign in to comment.