| Total Complexity | 4 |
| Complexity/F | 4 |
| Lines of Code | 29 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 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 |