config/passport.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 1.33

Size

Lines of Code 18
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 0
wmc 4
c 2
b 0
f 1
nc 1
mnd 1
bc 2
fnc 3
dl 0
loc 18
rs 10
bpm 0.6666
cpm 1.3333
noi 1

2 Functions

Rating   Name   Duplication   Size   Complexity  
A exports.ensureAuthenticated 0 4 2
A passport.js ➔ ??? 0 1 1
1
// Auth
2
var passport = require('passport')
3
var mongoose = require('mongoose')
4
var User = mongoose.model('User')
5
var local = require('./passport/local')
6
var google = require('./passport/google')
7
8
// serialize sessions
9
passport.serializeUser((user, cb) => cb(null, user.id))
10
passport.deserializeUser((id, cb) => User.load({ criteria: { _id: id } }, cb))
11
12
// use these strategies
13
passport.use(local)
14
passport.use(google)
15
16
exports.ensureAuthenticated = function (req, res, next) {
17
  if (req.isAuthenticated()) { return next() }
18
  res.redirect('/auth/login')
0 ignored issues
show
Best Practice introduced by
There is no return statement in this branch, but you do return something in other branches. Did you maybe miss it? If you do not want to return anything, consider adding return undefined; explicitly.
Loading history...
19
}
20