arshia-gh / Project-Aid-Hub

Project Aid Hub

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Organization representatives can be registered without email and mobileNo

arshia-gh opened this issue · comments

Back-end API allows representatives to be registered without providing email and mobileNo fields

Example Input

username: OPMichael
fullname: Michael Wijaya
jobTitle: CEO

Expected Output

{
	"error": {
		"message": "some fields did not meet the validation requirements",
		"name": "ValidationError",
		"fields": {
			"email": "email is required",
			"mobileNo": "mobileNo is required"
		}
	},
	"code": 400
}

Actual Output

{
	"error": {
		"message": "something has gone wrong, please contact the administrators"
	},
	"code": 500
}

Note: as the server attempts to send an email to an undefined value, a 500 Error occurs.

err: {
      "type": "Error",
      "message": "No recipients defined",
      "stack":
          Error: No recipients defined
              at SMTPConnection._formatError (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:784:19)
              at SMTPConnection._setEnvelope (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:1001:34)
              at SMTPConnection.send (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:615:14)
              at sendMessage (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-transport\index.js:227:28)
              at C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-transport\index.js:285:25
              at SMTPConnection._actionAUTHComplete (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:1550:9)
              at SMTPConnection.<anonymous> (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:540:26)
              at SMTPConnection._processResponse (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:947:20)
              at SMTPConnection._onData (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:749:14)
              at TLSSocket.SMTPConnection._onSocketData (C:\Users\Arshia Gholami\Documents\BIT216\project_aid_hub\server\node_modules\nodemailer\lib\smtp-connection\index.js:189:44)
      "code": "EENVELOPE",
      "command": "API"
    }

fixed