Skip to content
This repository has been archived by the owner on Aug 30, 2021. It is now read-only.

adding ability to configure session.secret in local env config #927

Merged
merged 1 commit into from
Oct 7, 2015

Conversation

jloveland
Copy link
Contributor

fixing #926

@@ -16,6 +16,7 @@ module.exports = {
// Enable mongoose debug mode
debug: process.env.MONGODB_DEBUG || false
},
sessionSecret: process.env.SESSION_SECRET || 'MEAN',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really required because it's already coming from default.js config

@lirantal lirantal added this to the 0.4.2 milestone Sep 21, 2015
@lirantal lirantal self-assigned this Sep 21, 2015
@jloveland
Copy link
Contributor Author

@lirantal, updated please let me know what you think

@mleanos
Copy link
Member

mleanos commented Sep 21, 2015

LGTM. I also like the addition of validateSessionSecret :) Thanks!

@lirantal
Copy link
Member

LGTM

@codydaig
Copy link
Member

LGTM.

Thanks! :-D

@@ -88,6 +88,23 @@ var validateSecureMode = function (config) {
};

/**
* Validate Session Secret parameter is not set to default in production
*/
var validateSessionSecret = function (config) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why a variable?

@ilanbiala
Copy link
Member

Can we get some tests for this?

@jloveland
Copy link
Contributor Author

@ilanbiala I will add some tests.

@jloveland
Copy link
Contributor Author

@ilanbiala added tests

@@ -88,6 +88,28 @@ var validateSecureMode = function (config) {
};

/**
* Validate Session Secret parameter is not set to default in production
*/
var validateSessionSecret = function (config, testing) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why this is a variable and not a named function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilanbiala that entire file is handled with variable functions like that: https://github.com/jloveland/mean/blob/local-session-secret/config/config.js , the validateSessionSecret is not an exception.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lirantal why is an anonymous function assigned to a variable better than a named function?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilanbiala I'm pretty sure that was a "standard" that a lot of projects picked up and ran with for Node. Currently the rest of the file and server side js files are this way, and for consistency should be kept this way until a refactor is done, which IMO is outside the scope of this PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ilanbiala you're missing the point. I'm not saying it's better or worse, I'm saying that the entire config.js file (https://github.com/jloveland/mean/blob/local-session-secret/config/config.js) makes use of the same style functions, i.e:

var getGlobbedPaths = function (globPatterns, excludes) {}
var validateEnvironmentVariable = function () {}
var validateSecureMode = function (config) {}
var validateSessionSecret = function (config, testing) {}
var initGlobalConfigFolders = function (config, assets) {}
and so on

I don't think that this PR or others should turn into code style PRs. If we want to change this we can opt for another PR to update to better code styles.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lirantal agreed, but let's add this to the list of things to fix up in the formatting issue you are going to create.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, np.

@codydaig
Copy link
Member

LGTM with the new tests

@lirantal
Copy link
Member

lirantal commented Oct 4, 2015

@jloveland can you please rebase so we can resolve the conflicts and merge?

@jloveland
Copy link
Contributor Author

this is ready to merge

@lirantal
Copy link
Member

lirantal commented Oct 7, 2015

Coverage increased, great work @jloveland ! :)

it('should accept default session secret when running in test', function (done) {
var conf = { sessionSecret: 'MEAN' };
config.utils.validateSessionSecret(conf, true).should.equal(true);
done();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be return done(). However, it doesn't look like there is any asynchronous code being tested, so why are we using done?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@lirantal @jloveland if this is indeed synchronous (which I think it is), then we should revert this PR and remove the callback because it's unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jloveland can you open a new PR to address the return done() standard as Ilan suggested?

@ilanbiala I agree with the async observation although for the sake of consistency and later updates to the tests it's ok to keep the done callback. After all, the code is not incorrect, but rather just uses a callback.

lirantal added a commit that referenced this pull request Oct 7, 2015
adding ability to configure session.secret in local env config
@lirantal lirantal merged commit 28ae5d6 into meanjs:master Oct 7, 2015
@jloveland
Copy link
Contributor Author

@ilanbiala thanks for the review!

@lirantal I can submit a new PR to fix the issue @ilanbiala pointed out.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants