Files
freeplanet_serverside/server/reg/registration.js

29 lines
552 B
JavaScript

const jwt = require('jsonwebtoken');
function toHexString(bytes) {
return Array.from(bytes, byte =>
("00" + (byte & 0xFF).toString(16)).slice(-2)
).join('');
}
module.exports = {
getlinkregByEmail: function (idapp, email, username) {
try{
mystr = idapp + email + username;
return jwt.sign(toHexString(mystr), process.env.SIGNCODE).toString();
} catch (e) {
console.error(e);
}
},
getiPAddressUser: function (req) {
try {
return req.ip; // Express
} catch (e) {
return ''
}
}
};