SignUp,SignIn,SignOut and email Validation for KeystoneJs.
-
Create keystone project using
yo keystone
. -
Install keystone-enreg
npm install git+https://[email protected]/enraiser/keystone-enreg.git
-
In keystone.js at keystone.init add email template
keystone.init({ …… 'emails': 'templates/emails', 'siteurl': 'http://mysite.com/', });
-
make sure you have set SITE_EMAIL_ADDRESS in .env file.
-
In routes/index.js inside module.exports
require('keystone-enreg').routes(app);
-
Add welcome.jade at templates/emails
block body-contents h1 Hi #{first_name}, p.text-larger We would like to verify your EmailID to enroll you on #{brand}. p.text-larger click a(href='#{link}') strong this link | to complete this verification.
-
In User model add a boolean field called valid
valid: { type: Boolean, initial: true},
-
In default.jade change SignIn and SignOut links and add SignUp link
if user if user.canAccessKeystone li: a(href='/keystone') Open Keystone li: a(href='/action/signout') Sign Out else li: a(href='/signin') Sign In li: a(href='/signup') Sign Up