Closed JdyxZ closed 1 year ago
I'm really silly. This is really hard to say...
I have just found the error after a lot of pain and time searching and you are not going to believe it. I overwrote the method getTime() of Date build-in class of Javascript with my implementation because I found it useless. Since express-sql-session uses this method in case no expiration time for the session is defined, this results in an error upon creating and processing a new expiration time. Indeed, here is the problem:
node_modules\express-mysql-session\index.js line 220
// Use whole seconds here; not milliseconds.
expires = Math.round(expires.getTime() / 1000);
data = JSON.stringify(data);
As you see, getTime() is invoked
My Date.getTime() implementation
Date.prototype.getTime2 = function()
{
return `${this.getHours().toString().padStart(2,"0")}:${this.getMinutes().toString().padStart(2, "0")}`
};
Moral: Never overwrite built-in methods.
Hi all,
I have programmed an app that uses local verification with passport and passport-local modules. I have implemented all the steps following a tutorial on the internet but I'm stuck in the error "ER_BAD_FIELD_ERROR: Unknown column 'NaN' in 'field list" that happens every time the code reaches a done method in my defined LocalStrategy. I use MySQL session to store the session in the database and connect-flash module to store data in global variables (I have read that connect-flash is no longer needed since passport already does the process and I have tried by using the notation {type: smth, message: smth}, but still doesn't work!). Then I use ejs as a view engine with express to render session messages in the views, but when the error prompts, the req.flash() doesn't work at all and global variables don't update. Before submitting the issue, I checked all DATABASE queries are working and checked that the request body is arriving well to routers, so any of these things cannot be the problem. Thank you in advance for your help and hope the fix of this issue helps somebody out there.
Main app js
Routers js
Passport js
Error
More info about the error