Deny users that already have a callsign registered
This commit is contained in:
parent
35e7a32b88
commit
fb8659a541
10
index.js
10
index.js
@ -18,12 +18,20 @@ const app = express();
|
||||
});
|
||||
|
||||
app.get('/signup', async (req, res) => {
|
||||
const { email, callsign } = req.query
|
||||
var { email, callsign } = req.query
|
||||
res.set("Access-Control-Allow-Origin", "*")
|
||||
if (!email) return res.json({ success: false, error: "Please provide an error" })
|
||||
if (!callsign) return res.json({ success: false, error: "Please provide a callsign" })
|
||||
if (!validator.isEmail(email)) return res.json({ success: false, error: "Please provide a (valid) email" })
|
||||
if (callsign.length > 7 || callsign.length < 3) return res.json({ success: false, error: "Please provide a (valid) callsign" })
|
||||
callsign = callsign.toLowerCase()
|
||||
var a = request('GET', 'https://mail.email.radio/api/v1/get/mailbox/all/email.radio', {
|
||||
headers: {
|
||||
'Content-Type': "application/json",
|
||||
'X-API-Key': process.env.MAILCOW_API_KEY,
|
||||
}}).getBody("utf8")
|
||||
var boxes = JSON.parse(a)
|
||||
if (boxes.find(box=>box.local_part == callsign.toLowerCase())) return res.json({ success: false, error: "There is already someone using this callsign. If someone is using your callsign, please email postmaster@email.radio" })
|
||||
await transporter.sendMail({
|
||||
from: process.env.SYSTEM_USERNAME, // sender address
|
||||
to: email, // list of receivers
|
||||
|
Loading…
Reference in New Issue
Block a user