在路由器代码上公开电子邮件地址是安全的吗?
It is secure to expose email address on router code?
将此代码用于 Google OAuthentication
// Authenticate route with bifurcation for admin and general users
// Solution based on:
// http://www.passportjs.org/docs/downloads/html/#custom-callback
router.get('/google/callback', (req, res, next) =>
passport.authenticate('google', (err, user, info) => {
if (err) return next(err);
if (!user) return res.redirect('/login');
req.logIn(user, err => {
if (err) return next(err);
if (req.user.email === 'adminemail@adminemail.com') return res.redirect('/admin');
return res.redirect('/dashboard');
});
})(req, res, next)
);
当然只有管理员邮箱被暴露了,根本没有密码。
无论如何,在路由器代码上公开电子邮件地址是安全的吗?
或者我是否需要将电子邮件写成全局变量或其他技巧?
代码将在服务器上执行,因此不会将电子邮件暴露给任何用户。
话虽这么说,但最好还是将其存储在一个变量中,例如管理员用户数组,这样如果您有更多用户,就可以对其进行扩展。
将此代码用于 Google OAuthentication
// Authenticate route with bifurcation for admin and general users
// Solution based on:
// http://www.passportjs.org/docs/downloads/html/#custom-callback
router.get('/google/callback', (req, res, next) =>
passport.authenticate('google', (err, user, info) => {
if (err) return next(err);
if (!user) return res.redirect('/login');
req.logIn(user, err => {
if (err) return next(err);
if (req.user.email === 'adminemail@adminemail.com') return res.redirect('/admin');
return res.redirect('/dashboard');
});
})(req, res, next)
);
当然只有管理员邮箱被暴露了,根本没有密码。
无论如何,在路由器代码上公开电子邮件地址是安全的吗?
或者我是否需要将电子邮件写成全局变量或其他技巧?
代码将在服务器上执行,因此不会将电子邮件暴露给任何用户。
话虽这么说,但最好还是将其存储在一个变量中,例如管理员用户数组,这样如果您有更多用户,就可以对其进行扩展。