Issues (791)

src/server/middlewares/checkCsrf.js (2 issues)

Severity
1
var middleware = function(err, req, res, next) {
2
  if (err.code !== 'EBADCSRFTOKEN') {
3
    return next(err)
4
  }else {
5
    if( req.url.indexOf('/abe/users/forgot') > -1 || req.url.indexOf('/abe/users/login') > -1 || !/^\/abe/.test(req.url)) {
6
      return next()
7
    }
8
  }
9
10
  var isHtml = /text\/html/.test(req.get('accept')) ? true : false
11
  if(isHtml) {
12
    res.redirect('/abe/users/login')
0 ignored issues
show
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...
13
  }else {
14
    var notAuthorized = {
15
      success: 0,
16
      message: 'form tampered with !'
17
    }
18
    res.set('Content-Type', 'application/json')
19
    res.send(JSON.stringify(notAuthorized))
0 ignored issues
show
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...
20
  }
21
}
22
23
export default middleware