diff --git a/server/routes/admin.js b/server/routes/admin.js
index 70a0445..6e78e78 100644
--- a/server/routes/admin.js
+++ b/server/routes/admin.js
@@ -3,6 +3,7 @@ import express from 'express'
import ensureLogin from '../../scripts/ensureLogin'
import wrap from '../../scripts/asyncRoute'
import API from '../api/admin'
+import Emailer from '../api/emailer'
import {User} from '../api'
const router = express.Router()
@@ -287,6 +288,21 @@ apiRouter.post('/ban', csrfVerify, wrap(async (req, res) => {
res.jsonp(result)
}))
+apiRouter.post('/email', csrfVerify, wrap(async (req, res) => {
+ if (!req.body.email) throw new Error('Email missing')
+ if (!req.body.title) throw new Error('Title missing')
+ if (!req.body.content) throw new Error('Content missing')
+
+ var message = {
+ subject: req.body.title,
+ html: req.body.content
+ }
+
+ let result = await Emailer.sendMail(req.body.email, message)
+
+ res.jsonp(result)
+}))
+
apiRouter.use((err, req, res, next) => {
console.error(err)
return res.status(400).jsonp({error: err.message})
diff --git a/src/script/component/MailerModal.vue b/src/script/component/MailerModal.vue
new file mode 100644
index 0000000..4d4b024
--- /dev/null
+++ b/src/script/component/MailerModal.vue
@@ -0,0 +1,59 @@
+
+ modal(:show='show', @close='close')
+ .modal-header
+ h3 Send Email
+ .modal-body.aligned-form
+ .alert.alert-danger(v-if='error') {{ error }}
+ .form-group
+ label(for="email") Email
+ input.form-control(type="email" id="email" name="email" v-model="email")
+ .form-group
+ label(for="title") Title
+ input.form-control(type="text" id="title" name="title" v-model="title")
+ .form-group
+ label(for="content") Content
+ textarea.form-control(type="text" id="content" name="content" v-model="content")
+ .modal-footer.text-right
+ button.btn.btn-primary(@click='submit') Done
+ button.btn.btn-secondary(@click='close') Cancel
+
+
+
diff --git a/src/script/component/User.vue b/src/script/component/User.vue
index 40e3f97..71c1256 100644
--- a/src/script/component/User.vue
+++ b/src/script/component/User.vue
@@ -40,6 +40,9 @@
.action(v-on:click='resetPassword')
i.fa.fa-fw.fa-envelope
| Password Email
+ .action(v-on:click='$parent.$emit("email", email)')
+ i.fa.fa-fw.fa-envelope
+ | Compose Email
.separator
.action(v-on:click='$parent.$emit("lock", id)' v-if="id != 1 && nw_privilege < 2")
i.fa.fa-fw.fa-lock
diff --git a/src/script/component/UserList.vue b/src/script/component/UserList.vue
index 4867839..409dd0b 100644
--- a/src/script/component/UserList.vue
+++ b/src/script/component/UserList.vue
@@ -10,6 +10,7 @@
ban-modal(:show='banning' @close='banning = 0' :id='banning')
user-modal(:show='editing' @close='editing = 0' :id='editing')
user-lock-modal(:show='locking' @close='locking = 0' :id='locking')
+ mailer-modal(:show='emailing' @close='emailing = null' :email='emailing')