Debugging
Signed-off-by: Fred Boniface <fred@fjla.uk>
This commit is contained in:
parent
a213014a0b
commit
e96f72a2fa
@ -7,6 +7,8 @@ const domains = require('../configs/domains.configs')
|
|||||||
|
|
||||||
async function createRegKey(body) {
|
async function createRegKey(body) {
|
||||||
log.out(`registerServices.createRegKey: Incoming request`, "INFO")
|
log.out(`registerServices.createRegKey: Incoming request`, "INFO")
|
||||||
|
if (!clean.checkEmailValid(body.mail)) {return {status: 400, message:"address format invalid"}
|
||||||
|
}
|
||||||
const domain = await clean.getDomainFromEmail(body.email) // The function should validate the email
|
const domain = await clean.getDomainFromEmail(body.email) // The function should validate the email
|
||||||
log.out(`registerServices: New registration request from domain: ${domain}`, "info")
|
log.out(`registerServices: New registration request from domain: ${domain}`, "info")
|
||||||
if (domains.includes(domain)) {
|
if (domains.includes(domain)) {
|
||||||
|
@ -43,9 +43,18 @@ async function getDomainFromEmail(mail) { // Needs testing
|
|||||||
return split[1]
|
return split[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function checkEmailValid(mail) {
|
||||||
|
const regex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
|
||||||
|
const result = mail.match(regex)
|
||||||
|
? true
|
||||||
|
: false; log.out(`sanitizerUtils.checkEmailValid: Invalid email format used: ${mail}`,"warn")
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
cleanApiEndpointTxt,
|
cleanApiEndpointTxt,
|
||||||
cleanApiEndpointNum,
|
cleanApiEndpointNum,
|
||||||
cleanNrcc,
|
cleanNrcc,
|
||||||
getDomainFromEmail
|
getDomainFromEmail,
|
||||||
|
checkEmailValid
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user