Skip to content

Commit

Permalink
Removing auth stuff that was added and now does not matter with a sha…
Browse files Browse the repository at this point in the history
…red user pool
  • Loading branch information
jonwinton committed Aug 31, 2017
1 parent e1605d3 commit 0c2f158
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 32 deletions.
7 changes: 1 addition & 6 deletions lib/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
};
};
Expand Down
20 changes: 0 additions & 20 deletions lib/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand All @@ -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);
});

Expand Down Expand Up @@ -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);
Expand Down
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 0c2f158

Please sign in to comment.