Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.59 KB | None | 0 0
  1. var adminSchema = new mongoose.Schema({
  2. companyName : {
  3. type: String,
  4. required: "Company name can't be empty.",
  5. required: false
  6. },
  7. companyID: {
  8. type: String,
  9. },
  10. address : {
  11. type: String,
  12. required: "Address can't be empty.",
  13. },
  14. contactDetails : {
  15. type: String,
  16. required: "Company contact number can't be empty.",
  17. },
  18. admins: {
  19. email : {
  20. type: String,
  21. required: "Email can't be empty.",
  22. unique: true
  23. },
  24. password: {
  25. type: String,
  26. required: "Password name can't be empty."
  27. },
  28. firstName : {
  29. type: String,
  30. required: "First name can't be empty."
  31. },
  32. lastName : {
  33. type: String,
  34. required: "Last name can't be empty."
  35. },
  36. phoneNumber : {
  37. type: String,
  38. required: "Reqired for further contact. Can't be empty."
  39. },
  40. designation : {
  41. type: String,
  42. required: "Designation can't be empty."
  43. },
  44. verified: {
  45. type: Boolean,
  46. default: false
  47. },
  48. role: String,
  49. emailResetTokenn: String,
  50. emailExpires: Date,
  51. saltSecret: String,//this is user for encryption and decryption of password
  52. users:[]
  53. }
  54. });
  55.  
  56. module.exports.registerAdmin = (req, res, next) =>{
  57.  
  58. var admin = new Admin();
  59. admin.companyName = req.body.companyName;
  60. admin.address = req.body.address;
  61. admin.contactDetails = req.body.contactDetails;
  62. admin.admins = {
  63. email : req.body.email,
  64. password: req.body.password,
  65. firstName : req.body.firstName,
  66. lastName : req.body.lastName,
  67. phoneNumber : req.body.phoneNumber,
  68. designation : req.body.designation,
  69. role : "admin",
  70. users: []
  71. };
  72.  
  73. {
  74. "admins": {
  75. "email": "losefivex@mrmail.info",
  76. "password": "$2a$10$pgkFZAfGwHkJ2e88/d2gUeWtjVdinxGmYGx5Euh69kgH95nCIUcNa",
  77. "firstName": "hdsdsds",
  78. "lastName": "Ghodsdsdsh",
  79. "phoneNumber": "4544343",
  80. "designation": "Software Engineer",
  81. "role": "admin",
  82. "users": [],
  83. "emailResetTokenn": "c833599ab72255a957007b42ca1cb8fddd566d7474b8b2b92bc08252f60184fa",
  84. "emailExpires": "2019-05-21T18:05:46.095Z",
  85. "saltSecret": "$2a$10$pgkFZAfGwHkJ2e88/d2gUe"
  86. },
  87. "_id": "5ce3e99a896e8c3ff5665702",
  88. "companyName": "Meta",
  89. "address": "AUS",
  90. "contactDetails": "54534454",
  91. "companyID": "675521",
  92. "__v": 0
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement