Completed
Push — master ( e7e1b8...a26a04 )
by Emil
02:49
created

v2/route/auth.js   A

Complexity

Total Complexity 12
Complexity/F 2

Size

Lines of Code 56
Function Count 6

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 77.27%

Importance

Changes 0
Metric Value
cc 0
eloc 33
nc 8
dl 0
loc 56
ccs 17
cts 22
cp 0.7727
crap 0
rs 10
c 0
b 0
f 0
wmc 12
mnd 1
bc 6
fnc 6
bpm 1
cpm 2
noi 2

1 Function

Rating   Name   Duplication   Size   Complexity  
A auth.js ➔ ??? 0 8 1
1 1
const express = require('express');
2 1
const router = express.Router();
3
4 1
const auth = require("../models/auth.js");
5
6 1
router.get('/api_key', (req, res) => {
7 1
    let data = {
8
        message: "",
9
        email: ""
10
    };
11
12 1
    res.render("api_key/form", data);
13
});
14
15 1
router.post('/api_key/confirmation', (req, res) => {
16 11
    if (req.body.gdpr && req.body.gdpr == "gdpr") {
17 9
        return auth.getNewAPIKey(res, req.body.email);
18
    }
19
20 2
    let data = {
21
        message: "Approve the terms and conditions.",
22
        email: req.body.email
23
    };
24
25 2
    res.render("api_key/form", data);
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...
26
});
27
28 1
router.get('/api_key/deregister', (req, res) => {
29
    let data = {
30
        message: "",
31
        email: "",
32
        apikey: ""
33
    };
34
35
    res.render("api_key/deregister", data);
36
});
37
38 1
router.post('/api_key/deregister', (req, res) => {
39 6
    if (req.body.email && req.body.apikey &&
40
        req.body.email.length > 0 && req.body.apikey.length > 0) {
41
        return auth.deregister(res, req.body);
42
    }
43
44
    let data = {
45
        message: "Both E-mail and API-key is needed to deregister.",
46
        email: "",
47
        apikey: ""
48
    };
49
50
    res.render("api_key/deregister", data);
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...
51
});
52
53 6
router.post('/login', (req, res) => auth.login(res, req.body));
54 5
router.post('/register', (req, res) => auth.register(res, req.body));
55
56
module.exports = router;
57