Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# fastify-basic-auth

[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](http://standardjs.com/) ![CI](https://github.com/fastify/fastify-basic-auth/workflows/CI/badge.svg)
![CI](https://github.com/fastify/fastify-basic-auth/workflows/CI/badge.svg?branch=master)
[![NPM version](https://img.shields.io/npm/v/fastify-basic-auth.svg?style=flat)](https://www.npmjs.com/package/fastify-basic-auth)
[![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-basic-auth/badge.svg)](https://snyk.io/test/github/fastify/fastify-basic-auth)
[![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://standardjs.com/)

A simple basic auth plugin for Fastify.

Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ function basicPlugin (fastify, opts, next) {
if (authenticateHeader) {
reply.header(authenticateHeader.key, authenticateHeader.value)
}
var credentials = auth(req)
const credentials = auth(req)
if (credentials == null) {
done(new Unauthorized('Missing or bad formatted authorization header'))
} else {
var result = validate(credentials.name, credentials.pass, req, reply, done)
const result = validate(credentials.name, credentials.pass, req, reply, done)
if (result && typeof result.then === 'function') {
result.then(done, done)
}
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@
},
"homepage": "https://github.com/fastify/fastify-basic-auth#readme",
"devDependencies": {
"@types/node": "^14.14.34",
"fastify": "^3.0.0",
"fastify-auth": "^1.0.0",
"standard": "^16.0.1",
"tap": "^14.10.7",
"tsd": "^0.11.0"
"tsd": "^0.14.0"
},
"dependencies": {
"basic-auth": "^2.0.1",
Expand Down