Open SamerElaila opened 6 years ago
https://github.com/facg3/MWM-Shop_Project/blob/e761e4d5a61dcf82570f808e98c8e50b8f240905/src/handler.js#L208
you can refactor this :
if (userData.role === 'admin') { token = jwt.sign(userData, process.env.SECRET_COOKIE); response.writeHead(200, { 'content-type': 'text/plain', 'Set-Cookie': `accessToken=${token}` }); response.end('/admin'); } else { token = jwt.sign(userData, process.env.SECRET_COOKIE); response.writeHead(200, { 'content-type': 'text/plain', 'Set-Cookie': `accessToken=${token}` }); response.end('/home');
to be like this :
token = jwt.sign(userData, process.env.SECRET_COOKIE); response.writeHead(200, { 'content-type': 'text/plain', 'Set-Cookie': `accessToken=${token}` }); if (userData.role === 'admin') { response.end('/admin'); } else { response.end('/home');
Done ty
https://github.com/facg3/MWM-Shop_Project/blob/e761e4d5a61dcf82570f808e98c8e50b8f240905/src/handler.js#L208
you can refactor this :
to be like this :