diff --git a/lib/auth.js b/lib/auth.js index 0c93e7c9..9d78d615 100644 --- a/lib/auth.js +++ b/lib/auth.js @@ -105,14 +105,9 @@ function isAuthenticated(site) { // try to authenticate with api key passport.authenticate('apikey', { session: false})(req, res, next); } else { - // We hae an issue where sites on subdomains of another clay site will not - // receive the correct site as an argument for this function, so we need - // to double-check - let possibleSite = sites.getSiteFromPrefix(`${site.host}${req.originalUrl}`); - req.session.returnTo = req.originalUrl; // redirect to this page after logging in // otherwise redirect to login - res.redirect(`${getAuthUrl(possibleSite || site)}/login`); + res.redirect(`${getAuthUrl(site)}/login`); } }; }; diff --git a/lib/auth.test.js b/lib/auth.test.js index c73ed4da..46b90b30 100644 --- a/lib/auth.test.js +++ b/lib/auth.test.js @@ -7,7 +7,6 @@ const filename = __filename.split('/').pop().split('.').shift(), sinon = require('sinon'), passport = require('passport'), winston = require('winston'), - sites = require('./services/sites'), passportTwitter = require('passport-twitter'), passportGoogle = require('passport-google-oauth'), passportSlack = require('passport-slack'), @@ -29,7 +28,6 @@ describe(_.startCase(filename), function () { sandbox.stub(responses, 'unauthorized'); // ldap is called directly, so we can't stub it sandbox.stub(passportAPIKey, 'Strategy'); - sandbox.stub(sites); sandbox.stub(db); }); @@ -86,24 +84,6 @@ describe(_.startCase(filename), function () { redirect: sandbox.spy() }; - sites.getSiteFromPrefix.returns({ host: 'domain.com', prefix: 'domain.com' }); - fn({ path: '/' })(req, res); // never calls next(), but checks synchronously - expect(req.session.returnTo).to.equal(req.originalUrl); - expect(res.redirect.callCount).to.equal(1); - }); - - it('falls back to default site if site service returns undefined', function () { - var req = { - isAuthenticated: () => false, - get: () => false, - originalUrl: 'domain.com', - session: {} - }, - res = { - redirect: sandbox.spy() - }; - - sites.getSiteFromPrefix.returns(undefined); fn({ path: '/' })(req, res); // never calls next(), but checks synchronously expect(req.session.returnTo).to.equal(req.originalUrl); expect(res.redirect.callCount).to.equal(1); diff --git a/package.json b/package.json index 5b3eb12a..36463515 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,12 @@ { "name": "amphora", -<<<<<<< HEAD "version": "4.0.0-rc1", -======= - "version": "3.6.0", ->>>>>>> master "description": "An API mixin for Express that saves, publishes and composes data with the key-value store of your choice.", "main": "index.js", "scripts": { - "test": "npm run eslint && npm run test-suite", + "test": "npm run eslint && npm run mocha", "eslint": "eslint --max-warnings 0 lib test", - "test-suite": "istanbul cover _mocha" + "mocha": "istanbul cover _mocha" }, "repository": { "type": "git",