Skip to content

Commit

Permalink
Fix bug in editing owner's account
Browse files Browse the repository at this point in the history
  • Loading branch information
EmilioImp committed Jan 12, 2020
1 parent abb58fa commit 4aab628
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion routes/ownerProfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const validationSchema = require('../validationSchemas.js');
const auth = require('../middleware/authorizationMiddleware.js');
const isOwner = require('../middleware/checkIfOwnerMiddleware.js');

const Sequelize = require('sequelize');
const Op = Sequelize.Op;

//Return profile data of the owner
router.get('/', auth, isOwner, async (req, res) => {
try {
Expand All @@ -25,9 +28,10 @@ router.get('/', auth, isOwner, async (req, res) => {
//Edit profile data of the owner
router.put('/', auth, inputValidator(validationSchema.editOwnerProfileValidation), isOwner, async (req, res) => {
try {
//check if the the email is already taken (it must be unique)
//check if the the email is already taken by another owner (it must be unique)
const owners = await Owner.findAll({
where: {
Username: {[Op.ne]: req.owner.Username},
Email: req.body.email
}
});
Expand Down

0 comments on commit 4aab628

Please sign in to comment.