Note: Those who are facing error in orginal git repository
- Error: Cannot enqueue Handshake after already enqueuing a Handshake. ( comment all // connection.connect(); and // connection.end(); in passport.js
- TypeError: Cannot read property 'insertId' of undefined ( resolve it by creating the users table manually in phpmyadmin using the provided code in scripts/create_Database.js)
mysql table create users code
DROP TABLE IF EXISTS users
;
CREATE TABLE IF NOT EXISTS users
(
id
int(10) UNSIGNED NOT NULL AUTO_INCREMENT,
username
varchar(20) NOT NULL,
password
char(60) NOT NULL,
PRIMARY KEY (id
),
UNIQUE KEY id_UNIQUE
(id
),
UNIQUE KEY username_UNIQUE
(username
)
) ENGINE=MyISAM AUTO_INCREMENT=8 DEFAULT CHARSET=latin1;
Code for the entire scotch.io tutorial series: Complete Guide to Node Authentication with MongoDB
Current version database is ported to MySQL
We will be using Passport to authenticate users locally,
If you would like to download the code and try it for yourself:
- Clone the repo:
git clone git@github.com:manjeshpv/node-express-passport-mysql.git
- Install packages:
npm install
- Edit the database configuration:
config/database.js
- Create the database schema:
node scripts/create_database.js
- Launch:
node server.js
- Visit in your browser at:
http://localhost:8080
Licence: 1