diff --git a/models/user.js b/models/user.js index 5ddc670..5704fc8 100644 --- a/models/user.js +++ b/models/user.js @@ -37,6 +37,7 @@ let model = db.define('user', { is_admin: { type: Sequelize.BOOLEAN }, is_show: { type: Sequelize.BOOLEAN }, + public_email: { type: Sequelize.BOOLEAN }, sex: { type: Sequelize.INTEGER } }, { diff --git a/modules/api.js b/modules/api.js index fb5c04c..92714d3 100644 --- a/modules/api.js +++ b/modules/api.js @@ -94,7 +94,8 @@ app.post('/api/sign_up', async (req, res) => { user = await User.create({ username: req.body.username, password: req.body.password, - email: req.body.email + email: req.body.email, + public_email: true }); await user.save(); @@ -134,7 +135,8 @@ app.get('/api/sign_up/:token', async (req, res) => { user = await User.create({ username: obj.username, password: obj.password, - email: obj.email + email: obj.email, + public_email: true }); await user.save(); diff --git a/modules/user.js b/modules/user.js index ed6767a..45e1a17 100644 --- a/modules/user.js +++ b/modules/user.js @@ -94,6 +94,7 @@ app.get('/user/:id', async (req, res) => { let statistics = await user.getStatistics(); await user.renderInformation(); + user.emailVisible = user.public_email || user.allowedEdit; res.render('user', { show_user: user, @@ -168,6 +169,7 @@ app.post('/user/:id/edit', async (req, res) => { user.information = req.body.information; user.sex = req.body.sex; + user.public_email = (req.body.public_email === 'on'); await user.save(); diff --git a/views/user.ejs b/views/user.ejs index 3acf9f1..2f98d26 100644 --- a/views/user.ejs +++ b/views/user.ejs @@ -49,12 +49,14 @@
<%= show_user.username %><% if (show_user.nameplate) { %><%- show_user.nameplate %><% } %>
-
-
-

Email

-
<%= show_user.email %>
-
-
+ <% if (show_user.emailVisible) { %> +
+
+

Email

+
<%= show_user.email %>
+
+
+ <% } %>

个性签名

diff --git a/views/user_edit.ejs b/views/user_edit.ejs index 379b7ba..94b09fa 100644 --- a/views/user_edit.ejs +++ b/views/user_edit.ejs @@ -25,6 +25,13 @@ readonly<% } %>>
+
+ +
+ checked<% } %>> + +
+