Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 77bd62c

Browse files
authored
Merge pull request #133 from MassiGy/block-eventSub-if-notEligible
Block event sub if not eligible
2 parents 56408b3 + da16d89 commit 77bd62c

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

‎src/controllers/Events/createEvent.js‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ module.exports.createEvent = async (req, res) => {
3535
description: req.body.description,
3636
host: req.body.host,
3737
status: req.body.status,
38+
eligibleProfiles: req.body.eligibleProfiles,
3839
date: req.body.date,
3940
ownerId: req.user.id,
4041
}
@@ -55,6 +56,7 @@ module.exports.createEvent = async (req, res) => {
5556
host: event.host,
5657
eventImage: event.eventImage,
5758
status: event.status,
59+
eligibleProfiles: event.eligibleProfiles,
5860
date: event.date,
5961
});
6062

‎src/controllers/Events/rsvpEvent.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,13 @@ module.exports.rsvpEvent = async (req, res) => {
4545
return res.status(400).send({ msg: 'Current user not found' });
4646
}
4747

48+
const eligible = event.eligibleProfiles.includes(user.status) || user.id === event.ownerId;
49+
50+
51+
if (!eligible) {
52+
return res.status(400).send({ msg: 'You are not eligilbe to subscribe to this event.' });
53+
}
54+
4855
const alreadySub = await user.hasEvent(event);
4956

5057
if (alreadySub) return res.status(400).send({ msg: 'You are already subscribed.' });

‎src/controllers/User/Account/signup.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ module.exports.signup = async (req, res) => {
9191
profilePicture: "https://fairfield-programming.herokuapp.com/duck/10001000005000043/",
9292
biography: "This user hasn't set a biography yet...",
9393
confirmed_email: false,
94-
status: "",
94+
status: req.body.userStatus,
9595
})
9696

9797
// generate token

‎src/models/Event.js‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = (sequelize, DataTypes) => {
66
host: DataTypes.STRING,
77
eventImage: DataTypes.TEXT,
88
status: DataTypes.STRING,
9+
eligibleProfiles: [DataTypes.STRING],
910
date: DataTypes.DATE,
1011
ownerId: DataTypes.INTEGER,
1112
});

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /