diff --git a/apps/webapp/src/hooks/mutations/useApiKeyMutation.tsx b/apps/webapp/src/hooks/mutations/useApiKeyMutation.tsx index 0f20a28df..deb60a4f8 100644 --- a/apps/webapp/src/hooks/mutations/useApiKeyMutation.tsx +++ b/apps/webapp/src/hooks/mutations/useApiKeyMutation.tsx @@ -13,7 +13,7 @@ const useApiKeyMutation = () => { // Fetch the token const loginResponse = await fetch(`${config.API_URL}/auth/login`, { method: 'POST', - body: JSON.stringify({ id_user: data.userId.trim(), password_hash: 'password_hashed_her' }), + body: JSON.stringify({ id_user: data.userId.trim(), password_hash: 'pwd_audrey123' }), headers: { 'Content-Type': 'application/json', }, @@ -22,7 +22,7 @@ const useApiKeyMutation = () => { if (!loginResponse.ok) { throw new Error('Failed to login'); } - const {access_token} = await loginResponse.json(); + const { access_token } = await loginResponse.json(); //console.log("token is "+ access_token) const response = await fetch(`${config.API_URL}/auth/generate-apikey`, { diff --git a/packages/api/scripts/seed.sql b/packages/api/scripts/seed.sql index 173585462..7f691de62 100644 --- a/packages/api/scripts/seed.sql +++ b/packages/api/scripts/seed.sql @@ -2,7 +2,7 @@ INSERT INTO organizations (id_organization, name, stripe_customer_id) VALUES ('55222419-795d-4183-8478-361626363e58', 'Acme Inc', 'cust_stripe_acme_56604f75-7bf8-4541-9ab4-5928aade4bb8' ); INSERT INTO users (id_user, email, password_hash, first_name, last_name, id_organization) VALUES -('0ce39030-2901-4c56-8db0-5e326182ec6b', 'audrey@aubry.io', 'password_hashed_here', 'Audrey', 'Aubry', +('0ce39030-2901-4c56-8db0-5e326182ec6b', 'audrey@aubry.io', 'pwd_audrey123', 'Audrey', 'Aubry', (SELECT id_organization FROM organizations WHERE name = 'Acme Inc')); DO $$ diff --git a/packages/api/src/@core/auth/auth.controller.ts b/packages/api/src/@core/auth/auth.controller.ts index 054771d75..7ca8e70d3 100644 --- a/packages/api/src/@core/auth/auth.controller.ts +++ b/packages/api/src/@core/auth/auth.controller.ts @@ -43,7 +43,6 @@ export class AuthController { @ApiOperation({ operationId: 'getApiKeys', summary: 'Retrieve API Keys' }) @ApiResponse({ status: 200 }) - @UseGuards(ApiKeyAuthGuard) @Get('api-keys') async apiKeys() { return this.authService.getApiKeys(); diff --git a/packages/api/src/app.controller.ts b/packages/api/src/app.controller.ts index 008db50b3..f2ebbbed7 100644 --- a/packages/api/src/app.controller.ts +++ b/packages/api/src/app.controller.ts @@ -1,6 +1,7 @@ -import { Controller, Get } from '@nestjs/common'; +import { Controller, Get, UseGuards } from '@nestjs/common'; import { AppService } from './app.service'; import { LoggerService } from '@@core/logger/logger.service'; +import { ApiKeyAuthGuard } from '@@core/auth/guards/api-key.guard'; @Controller() export class AppController { @@ -15,4 +16,10 @@ export class AppController { getHello(): string { return this.appService.getHello(); } + + @UseGuards(ApiKeyAuthGuard) + @Get('protected') + getHello2(): string { + return `Hello You Are On The Panora API PROTECTED endpoint!`; + } }