add org field in db

This commit is contained in:
Priyatham Sai chand 2022-05-08 22:21:32 +05:30
parent c3d665d62e
commit 3729bff2e1
No known key found for this signature in database
GPG Key ID: C3DFD0A2F6675222
3 changed files with 2421 additions and 15 deletions

2418
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ const { OAuth2Client } = require('google-auth-library');
router.post("/register", async (req, res) => { router.post("/register", async (req, res) => {
try { try {
let { username,email,phonenumber,password} = req.body; let { username,email,phonenumber,password,organization} = req.body;
@ -34,6 +34,7 @@ router.post("/register", async (req, res) => {
email, email,
phonenumber, phonenumber,
password: passwordHash, password: passwordHash,
organization
}); });
const savedUser = await newUser.save(); const savedUser = await newUser.save();
res.json(savedUser); res.json(savedUser);
@ -112,7 +113,8 @@ router.get("/", auth, async (req, res) => {
id: user._id, id: user._id,
pricing: user.pricing, pricing: user.pricing,
email: user.email, email: user.email,
phonenumber: user.phonenumber phonenumber: user.phonenumber,
organization: user.organization
}); });
}); });
router.put("/update", async (req, res) => { router.put("/update", async (req, res) => {
@ -183,4 +185,4 @@ router.post("/googlelogin", async (req, res) => {
}); });
}); });
module.exports = router; module.exports = router;

View File

@ -26,8 +26,14 @@ const UserSchema = mongoose.Schema({
enum: ['free','basic','intermediate','luxury'], enum: ['free','basic','intermediate','luxury'],
default:'free', default:'free',
required:false required:false
} },
organization: {
type:String,
enum: ['mod','tenant','owner'],
default:'mod',
required:false
},
}); });
module.exports = User = mongoose.model('user',UserSchema); module.exports = User = mongoose.model('user',UserSchema);