pis #12

Merged
fred.boniface merged 95 commits from pis into main 2023-05-06 21:54:51 +01:00
2 changed files with 6 additions and 3 deletions
Showing only changes of commit 155a3c588c - Show all commits

View File

@ -2,7 +2,9 @@ module.exports = statusCodes = {
700: "no authentication attempt",
701: "invalid credentials",
702: "domain whitelisted",
703: "registration request not found, maybe expired",
800: "location code not found",
801: "unable to fetch location data",
900: "invalid request format",
950: "upstream server error",
}

View File

@ -4,6 +4,7 @@ const db = require('./dbAccess.services')
const mail = require('./mail.services')
const clean = require('../utils/sanitizer.utils')
const domains = require('../configs/domains.configs')
const errors = require('../configs/errorCodes.configs')
async function createRegKey(body) {
log.out(`registerServices.createRegKey: Incoming request`, "INFO")
@ -22,9 +23,9 @@ async function createRegKey(body) {
if (await mail.send(message) == true) {
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
@ -40,7 +41,7 @@ async function regUser(req) { // Add input validation
return {status: 201, message: "User added", api_key: uuid}
}
}
return {status: 401, message: "Unauthorised"}
return {status: 401, errorCode: 703, errorMsg: errors[703]}
}
module.exports = {