Add email verification and notifications
This commit - [x] Fixes the flash notice color (Trivial) - [x] Adds flash message for user with no email. - [x] Adds checks to see if user's email is verified, and displays corresponding notification. - [x] Adds email templates.
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import dedent from 'dedent';
|
||||
|
||||
export function ifNoUserRedirectTo(url, message, type = 'errors') {
|
||||
return function(req, res, next) {
|
||||
const { path } = req;
|
||||
@@ -28,3 +30,24 @@ export function ifNoUser401(req, res, next) {
|
||||
}
|
||||
return res.status(401).end();
|
||||
}
|
||||
|
||||
export function flashIfNotVerified(req, res, next) {
|
||||
const user = req.user;
|
||||
if (!user) {
|
||||
return next();
|
||||
}
|
||||
const email = req.user.email;
|
||||
const emailVerified = req.user.emailVerified;
|
||||
if (!email) {
|
||||
req.flash('info', { msg:
|
||||
dedent `Please update your email address when you get a moment in
|
||||
your <a href="\settings"> Settings Page.</a>`
|
||||
});
|
||||
} else if (!emailVerified) {
|
||||
req.flash('info', { msg:
|
||||
dedent `We have your email address with us, but its not yet verified.
|
||||
Please follow the link we sent you, when you get a moment.`
|
||||
});
|
||||
}
|
||||
return next();
|
||||
}
|
||||
|
Reference in New Issue
Block a user