Skip to content

Commit

Permalink
Fixes on API keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Rachid Flih authored and Rachid Flih committed Aug 1, 2024
1 parent 02d75ba commit d5c8fc2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/api/src/@core/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,14 @@ export class AuthService {



async getProjectIdForApiKey(apiKey: string) {
async getProjectIdForApiKey(hashed_apiKey: string) {
try {
const hashed_key = crypto.createHash('sha256').update(apiKey).digest('hex');
const saved_api_key = await this.prisma.api_keys.findUnique({
where: {
api_key_hash: hashed_key,
api_key_hash: hashed_apiKey,
},
});

return saved_api_key.id_project;
} catch (error) {
throw error;
Expand All @@ -403,9 +403,9 @@ export class AuthService {
// TO DO : add Expiration in part 3

// Decode the JWT to verify if it's valid and get the payload
const decoded = this.jwtService.verify(apiKey, {
secret: process.env.JWT_SECRET,
});
// const decoded = this.jwtService.verify(apiKey, {
// secret: process.env.JWT_SECRET,
// });


// pseudo-code:
Expand Down
4 changes: 4 additions & 0 deletions packages/api/src/@core/connections/@utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ export class ConnectionUtils {
token: string,
): Promise<ConnectionMetadata> {
try {
console.log('**********')
console.log(token);
console.log('**********')

const res = await this.prisma.connections.findFirst({
where: {
connection_token: token,
Expand Down

0 comments on commit d5c8fc2

Please sign in to comment.