mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: use the same Authorization header for jwt and api key
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as bcrypt from 'bcrypt';
|
||||
import { AuthApiKeyPrefix } from './Auth.constants';
|
||||
|
||||
export const hashPassword = (password: string): Promise<string> =>
|
||||
new Promise((resolve) => {
|
||||
@@ -8,3 +9,12 @@ export const hashPassword = (password: string): Promise<string> =>
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Extracts and validates an API key from the Authorization header
|
||||
* @param {string} authorization - Full authorization header content.
|
||||
*/
|
||||
export const getAuthApiKey = (authorization: string) => {
|
||||
const apiKey = authorization.toLowerCase().replace('bearer ', '').trim();
|
||||
return apiKey.startsWith(AuthApiKeyPrefix) ? apiKey : '';
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user