diff --git a/README.md b/README.md index 50f0bbd..95d729d 100644 --- a/README.md +++ b/README.md @@ -5,12 +5,6 @@ CHECK OUT OUR [GETTING STARTED DOC](docs/GETTING_STARTED.md) FOR A STEP BY STEP [![Release Branch](https://img.shields.io/badge/release_branch-main-green.svg)](https://github.com/digitalcredentials/admin-dashboard/tree/main) [![License](https://img.shields.io/badge/license-mit-blue.svg)](https://github.com/digitalcredentials/admin-dashboard/blob/main/LICENSE) -
- - - -
- A system for: * uploading and managing credential data diff --git a/src/CHANGELOG.md b/src/CHANGELOG.md new file mode 100644 index 0000000..b347aeb --- /dev/null +++ b/src/CHANGELOG.md @@ -0,0 +1,7 @@ +# admin-dashboard Changelog + +## 0.1.1 - 2024-03-25 +### Changed +- fixed error when no auth header present PR #39 + +For previous history, see Git commits. \ No newline at end of file diff --git a/src/endpoints/getCredentialLinks.ts b/src/endpoints/getCredentialLinks.ts index 3c6b86c..98032a1 100644 --- a/src/endpoints/getCredentialLinks.ts +++ b/src/endpoints/getCredentialLinks.ts @@ -12,18 +12,14 @@ const tenantName = process.env.TENANT_NAME ?? 'test'; export const getCredentialLinks: PayloadHandler = async (req, res) => { let id: string; + let token: string; - const authHeader = req.headers.authorization; - - if (!authHeader.startsWith('Bearer ')) return res.sendStatus(401); - - const token = authHeader.split('Bearer ')[1]; - - try { + try { + const authHeader = req.headers.authorization; + if (authHeader && !authHeader.startsWith('Bearer ')) return res.sendStatus(401); + token = authHeader.split('Bearer ')[1]; const decoded = jwt.verify(token, secret); - if (typeof decoded === 'string' || !decoded.id) return res.sendStatus(401); - id = decoded.id; } catch (error) { return res.sendStatus(401);