Route/Auth.js   A
last analyzed

Complexity

Total Complexity 4
Complexity/F 4

Size

Lines of Code 29
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A Auth.js ➔ GetToken 0 11 4
1
var jwt = require('express-jwt')
2
var key = require('../Config/Key')
3
4
function GetToken(request) {
5
    if(request.headers.authorization) {
6
        const split = request.headers.authorization.split(' ')
7
8
        if(split[0] === 'Token' || split[0] === 'Bearer') {
9
            return split[1]
10
        }
11
    }
12
13
    return null
14
}
15
16
module.exports = {
17
    required: jwt({
18
        secret: key.private_keyphrase,
19
        userProperty: 'payload',
20
        getToken: GetToken
21
    }),
22
23
    optional: jwt({
24
        secret: key.private_keyphrase,
25
        userProperty: 'payload',
26
        credentialsRequired: false,
27
        getToken: GetToken
28
    })
29
}
30