Answer the question
In order to leave comments, you need to log in
Am I dumb or what? What's up with monga?
When registering a user in mongo, 2 fields are written: confirm_code: "SHA512 hash" и confirmed: false
After he follows the confirmation link, the confirmed field changes to true.
REALLY CHANGING ! I see the result in the console - IT'S TRUE !
Now, during authorization, we check this field and if it is not true, but IT is TRUE , then we do not let it into the site. But this field is returned as undefined. Here's a snippet of code:
User
.getUser({
email: authObj.email,
password: _password
},
function (err, user) {
if (err) {
console.log(err);
}
if (!user) {
errors.push("Неверный Email или пароль!");
return res.status(400).json({
error: true,
messages: errors
});
}
console.log("CONFIRMED:", user.confirmed); // <- undefined, а в БД оно TRUE
//#TODO:FIXME
if (!user.confirmed) {
errors.push("Не подтвержденный Email! Перейдите по ссылке в письме для подтверждения Email.");
return res.status(403).json({
error: true,
messages: errors
});
}
else {
// ... здесь пишем в сессию и т. д. Короче авторизация юзера. Но до этого места не срабатывает.
Answer the question
In order to leave comments, you need to log in
Guess what happened!!!!!!!!!!!
I deer added a list of fields to the select conditions:
And didn't include the email verification field here......
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question