Skip to content

Commit

Permalink
Merge b802b01 into 0ad9f48
Browse files Browse the repository at this point in the history
  • Loading branch information
brettz9 committed May 9, 2019
2 parents 0ad9f48 + b802b01 commit 3bdcaf9
Show file tree
Hide file tree
Showing 43 changed files with 2,193 additions and 1,301 deletions.
3 changes: 2 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.git
coverage/
node_modules/
node_modules/
var/
117 changes: 104 additions & 13 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,115 @@
module.exports = {
env: {
// jest: true,
mocha: true,
node: true,
browser: false
},
extends: [
'airbnb-base',
'ash-nazg/sauron-node',
// Override ash-nazg's current preference for ESM
'plugin:node/recommended-script'
],
settings: {
jsdoc: {
// For `jsdoc/check-examples` in `ash-nazg`
matchingFileName: 'dummy.md',
rejectExampleCodeRegex: '^`',
}
},
overrides: [
{
files: ['test/**'],
env: {
// jest: true,
mocha: true
},
globals: {
expect: 'readonly'
},
rules: {
// 'jest/no-disabled-tests': [2],
// 'jest/no-focused-tests': [2],
// 'jest/no-identical-title': [2],
// 'jest/prefer-to-have-length': [2],
// 'jest/valid-expect': [2],
}
},
{
files: ['**/*.md'],
rules: {
'eol-last': 'off',
'no-console': 'off',
'no-undef': 'off',
'no-unused-vars': 'warn',
'padded-blocks': 'off',
'import/unambiguous': 'off',
'import/no-unresolved': 'off',
'node/no-missing-import': 'off',
'node/no-missing-require': 'off',
'func-names': 'off',
'import/newline-after-import': 'off',
strict: 'off',
// Disable until eslint-plugin-jsdoc may fix: https://github.com/gajus/eslint-plugin-jsdoc/issues/211
indent: 'off'
}
}
],
globals: {
// By some ESLint bug, config overrides not working with globals
require: 'readonly',
module: 'readonly',
exports: 'writable'
},
plugins: [
// 'jest'
],
rules: {
"comma-dangle": 0,
"no-underscore-dangle": 0,
"no-param-reassign": 0,
"prefer-destructuring": 0,
// 'jest/no-disabled-tests': [2],
// 'jest/no-focused-tests': [2],
// 'jest/no-identical-title': [2],
// 'jest/prefer-to-have-length': [2],
// 'jest/valid-expect': [2],
'comma-dangle': 0,
'no-underscore-dangle': 0,
'no-param-reassign': 0,

// Disable until implementing promises and Node version supporting
'promise/prefer-await-to-callbacks': 0,
'promise/prefer-await-to-then': 0,

// Disable until ready to tackle
'require-jsdoc': 0,

// Disable current preferences of ash-nazg
'import/no-commonjs': 0,
'node/exports-style': 0,

// add back different or stricter rules from airbnb
'object-curly-spacing': ['error', 'always'],
'func-names': 'warn',
'max-len': ['error', 100, 2, {
ignoreUrls: true,
ignoreComments: false,
ignoreRegExpLiterals: true,
ignoreStrings: true,
ignoreTemplateLiterals: true,
}],
'space-before-function-paren': ['error', {
anonymous: 'always',
named: 'never',
asyncArrow: 'always'
}],
'no-multiple-empty-lines': ['error', { max: 2, maxEOF: 0 }],
'arrow-parens': ['error', 'as-needed', {
requireForBlockBody: true,
}],
'no-empty-function': ['error', {
allow: [
'arrowFunctions',
'functions',
'methods',
]
}],
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }],
'no-multi-assign': ['error'],
'no-unused-expressions': ['error', {
allowShortCircuit: false,
allowTernary: false,
allowTaggedTemplates: false,
}]
}
};
};
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
docs/
reports/
var/

# Mac OS X
.DS_Store
Expand Down
18 changes: 0 additions & 18 deletions .jshintrc

This file was deleted.

2 changes: 1 addition & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ docs/
examples/
reports/
test/
var/

.github/
.jshintrc
.travis.yml
.gitlab-ci.yml
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Contributing

Pull Requests are welcome for any issues, if you have any questions please
Pull Requests are welcome for any issues, if you have any questions please
[raise an issue](https://github.com/passport-next/passport/issues).

If you discover a security issue please create an issue stating you've discovered a security
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ view-docs:
open ./docs/index.html

view-cov:
open ./reports/coverage/lcov-report/index.html
open ./var/cov/index.html

clean: clean-docs clean-cov
-rm -r $(REPORTSDIR)
Expand Down
34 changes: 17 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Passport Next aims to:
* Follow [Semantic Versioning](https://semver.org/)
* Keep an up to date CHANGELOG.md

**Passport Next does not aim to be backwards compatible with the upstream repositories.
**Passport Next does not aim to be backwards compatible with the upstream repositories.
The changes required to keep up to date and functioning prohibit that so if you're migrating
from the upstream modules please test your code thouroughly!**

Expand All @@ -62,8 +62,8 @@ application must be configured.

```javascript
passport.use(new LocalStrategy(
function(username, password, done) {
User.findOne({ username: username }, function (err, user) {
function (username, password, done) {
User.findOne({ username }, function (err, user) {
if (err) { return done(err); }
if (!user) { return done(null, false); }
if (!user.verifyPassword(password)) { return done(null, false); }
Expand All @@ -88,11 +88,11 @@ as simple as serializing the user ID, and finding the user by ID when
deserializing.

```javascript
passport.serializeUser(function(user, done) {
passport.serializeUser(function (user, done) {
done(null, user.id);
});

passport.deserializeUser(function(id, done) {
passport.deserializeUser(function (id, done) {
User.findById(id, function (err, user) {
done(err, user);
});
Expand All @@ -108,8 +108,8 @@ persistent login sessions (recommended, but not required), `passport.session()`
middleware must also be used.

```javascript
var app = express();
app.use(require('serve-static')(__dirname + '/../../public'));
const app = express();
app.use(require('serve-static')(path.join(__dirname, '/../../public')));
app.use(require('cookie-parser')());
app.use(require('body-parser').urlencoded({ extended: true }));
app.use(require('express-session')({ secret: 'keyboard cat', resave: true, saveUninitialized: true }));
Expand All @@ -123,31 +123,31 @@ Passport provides an `authenticate()` function, which is used as route
middleware to authenticate requests.

```javascript
app.post('/login',
app.post('/login',
passport.authenticate('local', { failureRedirect: '/login' }),
function(req, res) {
function (req, res) {
res.redirect('/');
});
```

#### Protect Routes When Using Sessions

Passport provides an `isAuthenticated()` function on the request object, which
is used to determine if the user has been authenticated and stored in the
Passport provides an `isAuthenticated()` function on the request object, which
is used to determine if the user has been authenticated and stored in the
session.

```javascript
app.post('/some/protected/route',
function(req, res, next) {
if(req.isAuthenticated()){
app.post('/some/protected/route',
function (req, res, next) {
if (req.isAuthenticated()) {
next();
} else {
next(new Error('Unauthorized'));
return;
}
next(new Error('Unauthorized'));
});
```

For a more complete solution to handling unauthenticated users, see
For a more complete solution to handling unauthenticated users, see
[connect-ensure-login](https://github.com/jaredhanson/connect-ensure-login), a
middleware to ensure login sessions.

Expand Down

0 comments on commit 3bdcaf9

Please sign in to comment.