Compare commits
6 Commits
carousel
...
carousel-i
Author | SHA1 | Date | |
---|---|---|---|
f8abf7cd48 | |||
8464c4debc | |||
dd6dc787e9 | |||
0f480af1f0 | |||
7dd862e134 | |||
|
489387ec9f |
Binary file not shown.
After Width: | Height: | Size: 529 KiB |
Binary file not shown.
After Width: | Height: | Size: 496 KiB |
Binary file not shown.
After Width: | Height: | Size: 396 KiB |
Binary file not shown.
After Width: | Height: | Size: 894 KiB |
Binary file not shown.
After Width: | Height: | Size: 592 KiB |
@@ -1,18 +1,17 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Carousel } from "react-bootstrap";
|
import { Carousel } from "react-bootstrap";
|
||||||
import "../styles/HomeCarousel.css";
|
export default class HomeCarousel extends React.Component {
|
||||||
export default class HomeCarousel extends React.Component{
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<Carousel>
|
<Carousel className="jumbotron" variant="light">
|
||||||
<Carousel.Item>
|
<Carousel.Item>
|
||||||
<img
|
<img
|
||||||
src='https://www.allanpanthera.com/wp-content/uploads/elementor/thumbs/79377445_m-o6r0ydib97moj7m7zg58w32qirim121wxt2i8thqyg.jpg'
|
className="d-block w-100"
|
||||||
|
src='/images/carousel/volleyball_normalized.jpg'
|
||||||
alt="Connect Slide"
|
alt="Connect Slide"
|
||||||
style={{ height: "300px", width: "2000px"}}
|
|
||||||
/>
|
/>
|
||||||
<Carousel.Caption>
|
<Carousel.Caption>
|
||||||
<div className="captionStyle">
|
<div className="captionStyle">
|
||||||
@@ -23,9 +22,9 @@ export default class HomeCarousel extends React.Component{
|
|||||||
</Carousel.Item>
|
</Carousel.Item>
|
||||||
<Carousel.Item>
|
<Carousel.Item>
|
||||||
<img
|
<img
|
||||||
src='http://cpadollard.com/wp-content/uploads/2018/01/cpa-dollard-fsc-banner-calendar_2000x300.jpg'
|
className="d-block w-100"
|
||||||
|
src='/images/carousel/schedule_normalized.jpg'
|
||||||
alt="Schedule Slide"
|
alt="Schedule Slide"
|
||||||
style={{ height: "300px", width: "2000px" }}
|
|
||||||
/>
|
/>
|
||||||
<Carousel.Caption>
|
<Carousel.Caption>
|
||||||
<div className="captionStyle">
|
<div className="captionStyle">
|
||||||
@@ -36,9 +35,9 @@ export default class HomeCarousel extends React.Component{
|
|||||||
</Carousel.Item>
|
</Carousel.Item>
|
||||||
<Carousel.Item>
|
<Carousel.Item>
|
||||||
<img
|
<img
|
||||||
src='https://tadvantagesites-com.cdn-convertus.com/uploads/sites/288/2019/07/Generic-Personal-Watercraft-3.jpg'
|
src='/images/carousel/rentals_normalized.jpg'
|
||||||
alt="Rent Slide"
|
alt="Rent Slide"
|
||||||
style={{ height: "300px", width: "2000px" }}
|
className="d-block w-100"
|
||||||
/>
|
/>
|
||||||
<Carousel.Caption>
|
<Carousel.Caption>
|
||||||
<div className="captionStyle">
|
<div className="captionStyle">
|
||||||
|
@@ -10,11 +10,7 @@ export default class Welcome extends React.Component {
|
|||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<div className="page-root">
|
<div className="page-root">
|
||||||
<div>
|
<HomeCarousel />
|
||||||
{/* <h1>Sports Matcher</h1>
|
|
||||||
<p>The best place to find a local match for a good game of your favourite sport!</p> */}
|
|
||||||
<HomeCarousel></HomeCarousel>
|
|
||||||
</div>
|
|
||||||
<div className="text-center p-3 mt-2">
|
<div className="text-center p-3 mt-2">
|
||||||
<h2>Why?</h2>
|
<h2>Why?</h2>
|
||||||
<p>Because you want to play the sports you love while meeting new friends!</p>
|
<p>Because you want to play the sports you love while meeting new friends!</p>
|
||||||
|
@@ -1,15 +0,0 @@
|
|||||||
.captionStyle {
|
|
||||||
background-color: seashell;
|
|
||||||
color: black;
|
|
||||||
outline: 1px solid black;
|
|
||||||
}
|
|
||||||
|
|
||||||
.carousel-control-next,
|
|
||||||
.carousel-control-prev /*, .carousel-indicators */ {
|
|
||||||
filter: invert(100%);
|
|
||||||
}
|
|
||||||
|
|
||||||
.carousel-indicators button {
|
|
||||||
filter: invert(100%);
|
|
||||||
}
|
|
||||||
|
|
@@ -1,19 +1,3 @@
|
|||||||
.jumbotron {
|
|
||||||
width: 100%;
|
|
||||||
padding-left: 1.5rem;
|
|
||||||
padding-right: 1.5rem;
|
|
||||||
padding-top: 12rem;
|
|
||||||
padding-bottom: 1rem;
|
|
||||||
text-align: center;
|
|
||||||
background-size: cover;
|
|
||||||
background-color: black;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
.jumbotron h1 {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.horizontal-scroller {
|
.horizontal-scroller {
|
||||||
overflow-x: scroll;
|
overflow-x: scroll;
|
||||||
}
|
}
|
||||||
|
@@ -26,8 +26,16 @@ MatchController.get("/search/:sport", needDatabase, async (req, res) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
|
MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
|
||||||
|
const user = req.user;
|
||||||
let limit = req.params.limit;
|
let limit = req.params.limit;
|
||||||
|
if (limit && typeof (limit) !== "number") {
|
||||||
|
res.status(400).send("Limit parameter is not a number.");
|
||||||
|
}
|
||||||
if (!req.params.limit) limit = 10;
|
if (!req.params.limit) limit = 10;
|
||||||
|
if (user) {
|
||||||
|
res.status(200).send(user.participatingMatches.slice(limit));
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (isNaN(limit)) {
|
if (isNaN(limit)) {
|
||||||
res.status(400).send("Limit parameter not a number.");
|
res.status(400).send("Limit parameter not a number.");
|
||||||
return;
|
return;
|
||||||
@@ -46,7 +54,6 @@ MatchController.get("/recent/:limit?", needDatabase, async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO: delete, update match.
|
|
||||||
MatchController.post("/", needDatabase, authenticationGuard, async (req, res) => {
|
MatchController.post("/", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const userId = req.session.userId;
|
const userId = req.session.userId;
|
||||||
@@ -73,6 +80,47 @@ MatchController.post("/", needDatabase, authenticationGuard, async (req, res) =>
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MatchController.patch("/:id", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
|
const match = await matchModel.findById(req.params.id);
|
||||||
|
if (!match) {
|
||||||
|
res.status(400).send("Invalid match ID provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.user._id !== match.creator && req.user.accessLevel < 3) {
|
||||||
|
res.status(401).send("Not authorized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body._id) {
|
||||||
|
res.status(400).send("Cannot change ID of match.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body.creator) {
|
||||||
|
res.status(400).send("Cannot change creator of match.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await match.updateOne(req.body);
|
||||||
|
|
||||||
|
res.status(200).send(match);
|
||||||
|
});
|
||||||
|
|
||||||
|
MatchController.delete("/:id", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
|
const match = await matchModel.findById(req.params.id);
|
||||||
|
if (!match) {
|
||||||
|
res.status(400).send("Invalid match ID provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.user._id !== match.creator && req.user.accessLevel < 3) {
|
||||||
|
res.status(401).send("Not authorized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
await match.deleteOne();
|
||||||
|
});
|
||||||
|
|
||||||
MatchController.get("/:matchId", needDatabase, async (req, res) => {
|
MatchController.get("/:matchId", needDatabase, async (req, res) => {
|
||||||
if (!req.params.matchId) {
|
if (!req.params.matchId) {
|
||||||
res.status(404).send("Id must be provided to retrieve match");
|
res.status(404).send("Id must be provided to retrieve match");
|
||||||
@@ -91,4 +139,51 @@ MatchController.get("/:matchId", needDatabase, async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MatchController.get("/join/:id", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
|
const match = await matchModel.findById(req.params.id);
|
||||||
|
const user = req.user;
|
||||||
|
if (!match) {
|
||||||
|
res.status(400).send("Invalid match ID provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.participatingMatches.includes(match._id)) {
|
||||||
|
res.status(400).send("Already participating in match.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
match.participants.push(user._id);
|
||||||
|
user.participatingMatches.push(match._id);
|
||||||
|
|
||||||
|
await match.save();
|
||||||
|
await user.save();
|
||||||
|
|
||||||
|
res.status(200).send("Joined.");
|
||||||
|
});
|
||||||
|
|
||||||
|
MatchController.get("/leave/:id", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
|
const match = await matchModel.findById(req.params.id);
|
||||||
|
const user = req.user;
|
||||||
|
|
||||||
|
if (!match) {
|
||||||
|
res.status(400).send("Invalid match ID provided.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!user.participatingMatches.includes(match._id)) {
|
||||||
|
res.status(400).send("Not part of match.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const userIndex = match.participants.indexOf(user._id);
|
||||||
|
match.participants.splice(userIndex, 1);
|
||||||
|
await match.save();
|
||||||
|
|
||||||
|
const matchIndex = user.participatingMatches.indexOf(match._id);
|
||||||
|
user.participatingMatches.splice(matchIndex, 1);
|
||||||
|
await user.save();
|
||||||
|
|
||||||
|
res.status(200).send("Left match.");
|
||||||
|
});
|
||||||
|
|
||||||
export default MatchController;
|
export default MatchController;
|
@@ -1,6 +1,7 @@
|
|||||||
import express from "express";
|
import express from "express";
|
||||||
import { authenticationGuard } from "../middleware/authority.js";
|
import { authenticationGuard } from "../middleware/authority.js";
|
||||||
import { needDatabase } from "../middleware/database.js";
|
import { needDatabase } from "../middleware/database.js";
|
||||||
|
import userModel from "../schemas/userModel.js";
|
||||||
import User from "../schemas/userModel.js";
|
import User from "../schemas/userModel.js";
|
||||||
const UserController = express.Router();
|
const UserController = express.Router();
|
||||||
|
|
||||||
@@ -49,84 +50,88 @@ UserController.get("/logout", authenticationGuard, (req, res) => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
UserController.get("/email/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
UserController.get("/:id?", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
let user = null;
|
||||||
const curUser = await User.findById(req.session.userId);
|
if (req.params.id) {
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
if (req.user.accessLevel > 2) {
|
||||||
if (selUser.email.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
user = await userModel.findById(req.params.id);
|
||||||
res.status(200).send({ email: selUser.email });
|
} else {
|
||||||
|
res.status(401).send("Unauthorized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res.status(401).send("Could not authenticate request.");
|
user = req.user;
|
||||||
}
|
}
|
||||||
|
user.password = undefined;
|
||||||
|
res.status(200).send(user);
|
||||||
});
|
});
|
||||||
|
|
||||||
UserController.get("/firstName/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
UserController.patch("/:id?", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
let user = null;
|
||||||
const curUser = await User.findById(req.session.userId);
|
if (req.params.id) {
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
if (req.user.accessLevel > 2) {
|
||||||
if (selUser.firstName.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
user = await userModel.findById(req.params.id);
|
||||||
res.status(200).send({ firstName: selUser.firstName });
|
} else {
|
||||||
|
res.status(401).send("Unauthorized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res.status(401).send("Could not authenticate request.");
|
user = req.user;
|
||||||
}
|
}
|
||||||
|
if (req.body._id) {
|
||||||
|
res.status(400).send("Cannot change user ID.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body.createdMatches) {
|
||||||
|
res.status(400).send("Cannot directly change the list of created matches.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body.password) {
|
||||||
|
res.status(400).send("Cannot directly change user password.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body.participatingMatches) {
|
||||||
|
res.status(400).send("Cannot directly change the list of participating matches.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body.joinDate) {
|
||||||
|
res.status(400).send("Cannot change the join date.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (req.body.accessLevel && req.user.accessLevel < 3) {
|
||||||
|
res.status(401).send("Unauthorized to change the access level of this user.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
await user.updateOne(req.body);
|
||||||
|
res.status(200).send("Updated.");
|
||||||
});
|
});
|
||||||
|
|
||||||
UserController.get("/lastName/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
/* TODO: Implement middleware for removing users.
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
|
||||||
const curUser = await User.findById(req.session.userId);
|
UserController.delete("/:id?", needDatabase, authenticationGuard, async (req, res) => {
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
let user = null;
|
||||||
if (selUser.lastName.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
if (req.params.id) {
|
||||||
res.status(200).send({ email: selUser.lastName });
|
if (req.user.accessLevel > 2) {
|
||||||
|
user = await userModel.findById(req.params.id);
|
||||||
|
} else {
|
||||||
|
res.status(401).send("Unauthorized.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
res.status(401).send("Could not authenticate request.");
|
user = req.user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await user.deleteOne();
|
||||||
|
res.status(200).send("Deleted user.");
|
||||||
});
|
});
|
||||||
|
|
||||||
UserController.get("/phone/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
*/
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
|
||||||
const curUser = await User.findById(req.session.userId);
|
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
|
||||||
if (selUser.phone.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
|
||||||
res.status(200).send({ phone: selUser.phone });
|
|
||||||
} else {
|
|
||||||
res.status(401).send("Could not authenticate request.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
UserController.get("/participatingMatches/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
|
||||||
const curUser = await User.findById(req.session.userId);
|
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
|
||||||
if (selUser.participatingMatches.public || curUser._id === selUser._id || curUser.accessLevel > 2) {
|
|
||||||
res.status(200).send({ participatingMatches: selUser.participatingMatches });
|
|
||||||
} else {
|
|
||||||
res.status(401).send("Could not authenticate request.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
UserController.get("/joinDate/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
|
||||||
const curUser = await User.findById(req.session.userId);
|
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
|
||||||
if (curUser._id === selUser._id || curUser.accessLevel > 2) {
|
|
||||||
res.status(200).send({ joinDate: selUser.joinDate });
|
|
||||||
} else {
|
|
||||||
res.status(401).send("Could not authenticate request.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
UserController.get("/createdMatches/:userId?", needDatabase, authenticationGuard, async (req, res) => {
|
|
||||||
if (!req.params.userId) req.params.userId = req.session.userId;
|
|
||||||
const curUser = await User.findById(req.session.userId);
|
|
||||||
const selUser = req.session.userId === req.params.userId ? curUser : await User.findById(req.params.userId);
|
|
||||||
if (curUser._id === selUser._id || curUser.accessLevel > 2) {
|
|
||||||
res.status(200).send({ createdMatches: selUser.createdMatches });
|
|
||||||
} else {
|
|
||||||
res.status(401).send("Could not authenticate request.");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO: Finish update requests using put.
|
|
||||||
|
|
||||||
UserController.post("/", needDatabase, async (req, res) => {
|
UserController.post("/", needDatabase, async (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
import MongoStore from "connect-mongo";
|
import MongoStore from "connect-mongo";
|
||||||
import session from "express-session";
|
import session from "express-session";
|
||||||
import { mongooseDbName, mongoURI } from "../database/mongoose.js";
|
import { mongooseDbName, mongoURI } from "../database/mongoose.js";
|
||||||
|
import userModel from "../schemas/userModel.js";
|
||||||
const sessionConf = {
|
const sessionConf = {
|
||||||
secret: process.env.SESSION_SECRET || "super duper secret string.",
|
secret: process.env.SESSION_SECRET || "super duper secret string.",
|
||||||
cookie: {
|
cookie: {
|
||||||
@@ -16,11 +17,12 @@ if (process.env.NODE_ENV === "production") {
|
|||||||
}
|
}
|
||||||
export const userSession = session(sessionConf);
|
export const userSession = session(sessionConf);
|
||||||
|
|
||||||
export function authenticationGuard(req, res, next) {
|
export async function authenticationGuard(req, res, next) {
|
||||||
if (req.session.userId) {
|
if (req.session.userId) {
|
||||||
|
req.user = await userModel.findById(req.session.userId);
|
||||||
next();
|
next();
|
||||||
} else {
|
} else {
|
||||||
res.sendStatus(401);
|
res.status(401).send("Not authorized.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,4 +24,17 @@ const matchSchema = new mongoose.Schema({
|
|||||||
createDate: { type: Date, required: true, default: Date.now }
|
createDate: { type: Date, required: true, default: Date.now }
|
||||||
});
|
});
|
||||||
|
|
||||||
|
matchSchema.pre("remove", function (next) {
|
||||||
|
const match = this;
|
||||||
|
match.populate("creator").populate("participants");
|
||||||
|
|
||||||
|
match.participants.forEach(participant => {
|
||||||
|
const index = participant.participatingMatches.indexOf(match._id);
|
||||||
|
participant.participatingMatches.splice(index, 1);
|
||||||
|
});
|
||||||
|
|
||||||
|
match.creator.createdMatches.splice(match.creator.createdMatches.indexOf(match._id), 1);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
|
||||||
export default mongoose.model(ModelNameRegister.Match, matchSchema);
|
export default mongoose.model(ModelNameRegister.Match, matchSchema);
|
Reference in New Issue
Block a user