weareopensource/Node

View on GitHub
modules/auth/controllers/auth.controller.js

Summary

Maintainability
A
0 mins
Test Coverage

Showing 0 of 13 total issues

Function oauthCallback has 45 lines of code (exceeds 25 allowed). Consider refactoring.
Wontfix

const oauthCallback = async (req, res, next) => {
const strategy = req.params.strategy;
// app Auth with Strategy managed on client side
if (req.body.strategy === false && req.body.key) {
try {
Severity: Minor
Found in modules/auth/controllers/auth.controller.js - About 1 hr to fix

    Function checkOAuthUserProfile has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
    Wontfix

    const checkOAuthUserProfile = async (profil, key, provider, res) => {
    // check if user exist
    try {
    const query = {};
    query[`providerData.${key}`] = profil.providerData[key];
    Severity: Minor
    Found in modules/auth/controllers/auth.controller.js - About 25 mins to fix

    TODO found
    Wontfix

    * TODO: escape deprecated

    Similar blocks of code found in 3 locations. Consider refactoring.
    Wontfix

    return res
    .status(200)
    .cookie('TOKEN', token, { httpOnly: true })
    .json({
    user,
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 2 other locations - About 2 hrs to fix
    modules/auth/controllers/auth.controller.js on lines 54..62
    modules/auth/controllers/auth.controller.js on lines 165..173

    Similar blocks of code found in 3 locations. Consider refactoring.
    Wontfix

    return res
    .status(200)
    .cookie('TOKEN', token, { httpOnly: true })
    .json({
    user,
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 2 other locations - About 2 hrs to fix
    modules/auth/controllers/auth.controller.js on lines 28..36
    modules/auth/controllers/auth.controller.js on lines 54..62

    Similar blocks of code found in 3 locations. Consider refactoring.
    Wontfix

    return res
    .status(200)
    .cookie('TOKEN', token, { httpOnly: true })
    .json({
    user,
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 2 other locations - About 2 hrs to fix
    modules/auth/controllers/auth.controller.js on lines 28..36
    modules/auth/controllers/auth.controller.js on lines 165..173

    Similar blocks of code found in 2 locations. Consider refactoring.
    Wontfix

    } else if (!user) {
    const _err = JSON.stringify(err);
    const path = 'token?message=Could%20not%20define%20user%20in%20oAuth';
    res.redirect(302, `${url}/${path}&error=${_err}`);
    } else {
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 1 other location - About 1 hr to fix
    modules/auth/controllers/auth.controller.js on lines 181..195

    Similar blocks of code found in 2 locations. Consider refactoring.
    Wontfix

    if (err) {
    const _err = JSON.stringify(err);
    const path = 'token?message=Unprocessable%20Entity';
    res.redirect(302, `${url}/${path}&error=${_err}`);
    } else if (!user) {
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 1 other location - About 1 hr to fix
    modules/auth/controllers/auth.controller.js on lines 185..195

    Identical blocks of code found in 5 locations. Consider refactoring.
    Wontfix

    const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
    expiresIn: config.jwt.expiresIn,
    });
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 4 other locations - About 40 mins to fix
    modules/auth/controllers/auth.controller.js on lines 25..27
    modules/auth/controllers/auth.controller.js on lines 51..53
    modules/auth/controllers/auth.controller.js on lines 85..87
    modules/auth/controllers/auth.controller.js on lines 162..164

    Identical blocks of code found in 5 locations. Consider refactoring.
    Wontfix

    const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
    expiresIn: config.jwt.expiresIn,
    });
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 4 other locations - About 40 mins to fix
    modules/auth/controllers/auth.controller.js on lines 51..53
    modules/auth/controllers/auth.controller.js on lines 85..87
    modules/auth/controllers/auth.controller.js on lines 162..164
    modules/auth/controllers/auth.controller.js on lines 190..192

    Identical blocks of code found in 5 locations. Consider refactoring.
    Wontfix

    const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
    expiresIn: config.jwt.expiresIn,
    });
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 4 other locations - About 40 mins to fix
    modules/auth/controllers/auth.controller.js on lines 25..27
    modules/auth/controllers/auth.controller.js on lines 51..53
    modules/auth/controllers/auth.controller.js on lines 162..164
    modules/auth/controllers/auth.controller.js on lines 190..192

    Identical blocks of code found in 5 locations. Consider refactoring.
    Wontfix

    const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
    expiresIn: config.jwt.expiresIn,
    });
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 4 other locations - About 40 mins to fix
    modules/auth/controllers/auth.controller.js on lines 25..27
    modules/auth/controllers/auth.controller.js on lines 51..53
    modules/auth/controllers/auth.controller.js on lines 85..87
    modules/auth/controllers/auth.controller.js on lines 190..192

    Identical blocks of code found in 5 locations. Consider refactoring.
    Wontfix

    const token = jwt.sign({ userId: user.id }, config.jwt.secret, {
    expiresIn: config.jwt.expiresIn,
    });
    Severity: Major
    Found in modules/auth/controllers/auth.controller.js and 4 other locations - About 40 mins to fix
    modules/auth/controllers/auth.controller.js on lines 25..27
    modules/auth/controllers/auth.controller.js on lines 85..87
    modules/auth/controllers/auth.controller.js on lines 162..164
    modules/auth/controllers/auth.controller.js on lines 190..192

    There are no issues that match your filters.

    Category
    Status