/* global requireShared */

const signToken = requireShared("utilities/signToken");


module.exports = (req, res) => {
    if (req.session.redirectUrl) {
        const url = `${req.session.redirectUrl}?accessToken=${signToken(req.user)}`;
        res.redirect(url);
    } else {
        res.status(202).send({accessToken: signToken(req.user)});
    }

    delete req.session.redirectUrl;
    return;
}
/* global requireShared */

const signToken = requireShared("utilities/signToken");
const {pick} = require("lodash");


module.exports = (req, res) => {

    const user = pick(req.user, ["_id", "email", "name"]);

    if (req.session.redirectUrl) {
        const url = `${req.session.redirectUrl}?accessToken=${signToken(user)}`;
        res.redirect(url);
    } else {
        res.status(202).send({accessToken: signToken(user)});
    }

    delete req.session.redirectUrl;
    return;
}
Add security so only selected value can be within the accesstoken (_id, email & name)
Add security so only selected value can be within the accesstoken (_id, email & name)
