pis #12
@ -2,7 +2,9 @@ module.exports = statusCodes = {
|
|||||||
700: "no authentication attempt",
|
700: "no authentication attempt",
|
||||||
701: "invalid credentials",
|
701: "invalid credentials",
|
||||||
702: "domain whitelisted",
|
702: "domain whitelisted",
|
||||||
|
703: "registration request not found, maybe expired",
|
||||||
800: "location code not found",
|
800: "location code not found",
|
||||||
801: "unable to fetch location data",
|
801: "unable to fetch location data",
|
||||||
900: "invalid request format",
|
900: "invalid request format",
|
||||||
|
950: "upstream server error",
|
||||||
}
|
}
|
@ -4,6 +4,7 @@ const db = require('./dbAccess.services')
|
|||||||
const mail = require('./mail.services')
|
const mail = require('./mail.services')
|
||||||
const clean = require('../utils/sanitizer.utils')
|
const clean = require('../utils/sanitizer.utils')
|
||||||
const domains = require('../configs/domains.configs')
|
const domains = require('../configs/domains.configs')
|
||||||
|
const errors = require('../configs/errorCodes.configs')
|
||||||
|
|
||||||
async function createRegKey(body) {
|
async function createRegKey(body) {
|
||||||
log.out(`registerServices.createRegKey: Incoming request`, "INFO")
|
log.out(`registerServices.createRegKey: Incoming request`, "INFO")
|
||||||
@ -22,9 +23,9 @@ async function createRegKey(body) {
|
|||||||
if (await mail.send(message) == true) {
|
if (await mail.send(message) == true) {
|
||||||
return {status: 201, message: "email sent"}
|
return {status: 201, message: "email sent"}
|
||||||
}
|
}
|
||||||
return {status: 500, message: "server error, email send failed"}
|
return {status: 500, errorCode: 950, errorMsg: errors[950]}
|
||||||
}
|
}
|
||||||
return {status: 403, message: "forbidden, domain is not on whitelist"}
|
return {status: 403, errorCode: 702, errorMsg: errors[702]}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function regUser(req) { // Add input validation
|
async function regUser(req) { // Add input validation
|
||||||
@ -40,7 +41,7 @@ async function regUser(req) { // Add input validation
|
|||||||
return {status: 201, message: "User added", api_key: uuid}
|
return {status: 201, message: "User added", api_key: uuid}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {status: 401, message: "Unauthorised"}
|
return {status: 401, errorCode: 703, errorMsg: errors[703]}
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
Reference in New Issue
Block a user