var genToken = require("../utils/tokenGenerator");
var access = require("../utils/access");
var params = require("../config/parameters");
-var checkNameEmail = require("../data/userCheck")
// to: object user (to who we send an email)
function setAndSendLoginToken(subject, to, res)
params.siteURL + "/authenticate?token=" + token + "\\n" +
"Token will expire in " + params.token.expire/(1000*60) + " minutes."
sendEmail(params.mail.noreply, to.email, subject, body, err => {
- // "id" is generally the only info missing on client side,
+
+ console.log("send login infos ::");
+ console.log(to);
+
+ // "id" is generally the only info missing on client side,
// but the name is also unknown if log-in with the email.
res.json(err || {id: to.id, name: to.name});
});
const name = req.body.name;
const email = req.body.email;
const notify = !!req.body.notify;
- const error = checkNameEmail({name: name, email: email});
+ const error = UserModel.checkNameEmail({name: name, email: email});
if (!!error)
return res.json({errmsg: error});
UserModel.create(name, email, notify, (err,uid) => {
router.get('/sendtoken', access.unlogged, access.ajax, (req,res) => {
const nameOrEmail = decodeURIComponent(req.query.nameOrEmail);
const type = (nameOrEmail.indexOf('@') >= 0 ? "email" : "name");
- const error = checkNameEmail({[type]: nameOrEmail});
+ const error = UserModel.checkNameEmail({[type]: nameOrEmail});
if (!!error)
return res.json({errmsg: error});
UserModel.getOne(type, nameOrEmail, (err,user) => {
router.put('/update', access.logged, access.ajax, (req,res) => {
const name = req.body.name;
const email = req.body.email;
- const error = checkNameEmail({name: name, email: email});
+ const error = UserModel.checkNameEmail({name: name, email: email});
if (!!error)
return res.json({errmsg: error});
const user = {