Skip to content

Commit

Permalink
Merge pull request #350 from alphagov/prevent-double-auth
Browse files Browse the repository at this point in the history
Prevent asking users to authenticate twice
  • Loading branch information
joelanman authored Jan 25, 2017
2 parents ba4d1d4 + a4f9ab4 commit 444c439
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ promoMode = promoMode.toLowerCase()
// Disable promo mode if docs aren't enabled
if (!useDocumentation) promoMode = 'false'

// Force HTTPs on production connections. Do this before asking for basicAuth to
// avoid making users fill in the username/password twice (once for `http`, and
// once for `https`).
if (env === 'production' && useHttps === 'true') {
app.use(utils.forceHttps)
}

// Authenticate against the environment-provided credentials, if running
// the app in production (Heroku, effectively)
if (env === 'production' && useAuth === 'true') {
Expand Down Expand Up @@ -104,11 +111,6 @@ app.locals.promoMode = promoMode
app.locals.releaseVersion = 'v' + releaseVersion
app.locals.serviceName = config.serviceName

// Force HTTPs on production connections
if (env === 'production' && useHttps === 'true') {
app.use(utils.forceHttps)
}

// Disallow search index idexing
app.use(function (req, res, next) {
// Setting headers stops pages being indexed even if indexed pages link to them.
Expand Down

0 comments on commit 444c439

Please sign in to comment.