Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release 1.1.0 #19

Merged
merged 277 commits into from
Mar 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
277 commits
Select commit Hold shift + click to select a range
b3a1892
idk how to stash changes, and im scared ;-;
ItsAnkan Jul 18, 2023
8e00d37
Test commit
Symbiot01 Jul 18, 2023
6f839dd
sahil' s work
ItsAnkan Jul 18, 2023
53dfa24
button
ItsAnkan Jul 18, 2023
8de8d9b
CSS of login register page
Symbiot01 Jul 18, 2023
8f95345
Updated form.scss for checkbox and radio styling.
Symbiot01 Jul 19, 2023
9a3195a
Updated form.scss for datetime styling.
Symbiot01 Jul 19, 2023
5eefeb1
Adding a bit more padding
Goose-Of-War Jul 19, 2023
3829d58
omae wa mo shindeiru
ItsAnkan Jul 19, 2023
222b18f
got the wrong repo at first
DishantB0411 Jul 19, 2023
945947a
the event login page
DishantB0411 Jul 19, 2023
5c0ccb3
Rename event-login to login.njk
DishantB0411 Jul 19, 2023
6e9ed75
Rename event-signup to signup.njk
DishantB0411 Jul 19, 2023
a73245b
hmmmmmmm
ItsAnkan Jul 19, 2023
25c9fa6
im dumb
ItsAnkan Jul 19, 2023
9a8c2a4
HMMMMMMMMMMMMMMMMMMMMMMMMMM
SachdevJai Jul 19, 2023
efa06c3
:sparkle:
SachdevJai Jul 19, 2023
7a36e54
Merge branch 'backend' of https://github.com/kgpmask/MASK-Event into …
ItsAnkan Jul 19, 2023
cd2f0fe
sahil messed up
ItsAnkan Jul 19, 2023
7646047
fixes ig
ItsAnkan Jul 19, 2023
c3d95fc
this should do it ig
ItsAnkan Jul 19, 2023
30b901a
made changes and added some css
DishantB0411 Jul 20, 2023
3f64407
removed the css
DishantB0411 Jul 20, 2023
148a8cb
That seems like a silly mistake
Goose-Of-War Jul 20, 2023
a2a3f1e
Forgot to change this
Goose-Of-War Jul 20, 2023
b61bcd7
password stuf
SachdevJai Jul 20, 2023
4f32e42
Removing test files
Goose-Of-War Jul 20, 2023
cf0e6aa
Merge pull request #4 from kgpmask/forms
Goose-Of-War Jul 20, 2023
66f7ad1
tests
SachdevJai Jul 20, 2023
1a38a99
Login tests
Goose-Of-War Jul 20, 2023
51c3447
Why am i doing this
Symbiot01 Jul 20, 2023
dd62a81
More tweaking of login
Goose-Of-War Jul 20, 2023
9cfa57d
Gaah copypasta skill issue
Goose-Of-War Jul 20, 2023
90bd189
Small misprint here and there so i fixed it
Symbiot01 Jul 20, 2023
dd1a667
Merge branch 'forms' into event-forms
Symbiot01 Jul 20, 2023
0f668ee
What to wite here is the biggest mystry of my life
Symbiot01 Jul 20, 2023
7efee5c
What to wite here is the biggest mystry of my life
Symbiot01 Jul 20, 2023
e8fc620
Merge branch 'event-forms' of https://github.com/kgpmask/MASK-Event i…
Symbiot01 Jul 20, 2023
dcc8014
soo many commits
Symbiot01 Jul 20, 2023
1e77ac9
one more commit haaaaaaaaaaaaaaaaaa
Symbiot01 Jul 20, 2023
e9ee423
pls fix regiter test
SachdevJai Jul 20, 2023
cedd8d3
This should help @SachdevJai
Goose-Of-War Jul 20, 2023
8ef294a
Added links in forms
Symbiot01 Jul 20, 2023
08690f7
Added links in forms
Symbiot01 Jul 20, 2023
9448caf
Invalid signup tests
Goose-Of-War Jul 20, 2023
966d56c
Merge branch 'event-forms' of https://github.com/kgpmask/MASK-Event i…
Symbiot01 Jul 20, 2023
a9d2940
GitHub test modification
Goose-Of-War Jul 20, 2023
f09381a
Hope this fixes it
Goose-Of-War Jul 20, 2023
3ad41fe
session delete fix
Goose-Of-War Jul 20, 2023
896448a
Lint??? GAAH
Goose-Of-War Jul 20, 2023
653b5f5
Connection timeout
Goose-Of-War Jul 20, 2023
7bf8abb
Connection timeout (fix)
Goose-Of-War Jul 20, 2023
e463a84
How is this bypassing lint???
Goose-Of-War Jul 20, 2023
922038b
Passing all tests hopefully
Goose-Of-War Jul 20, 2023
749b07f
Refining
Symbiot01 Jul 20, 2023
d0b3698
Dearest god of webdev I pray to thou
Goose-Of-War Jul 20, 2023
43b6193
Dearest god of webdev I pray to thee
Goose-Of-War Jul 20, 2023
cc90d69
Right... the extra await functions take up more time
Goose-Of-War Jul 20, 2023
e7b0fba
Final touches
Goose-Of-War Jul 20, 2023
dc601fb
Merge pull request #6 from kgpmask/event-forms
Goose-Of-War Jul 20, 2023
22bc099
Frontend integration merge
Goose-Of-War Jul 20, 2023
add4da4
Dishant's a contributor too
Goose-Of-War Jul 21, 2023
839b3af
Frontend is pain
ItsAnkan Jul 21, 2023
a46ae46
Atleast getData() is working now
ItsAnkan Jul 21, 2023
b71fa94
Login signup working
ItsAnkan Jul 21, 2023
4e780ef
Test for rendering pages
Goose-Of-War Jul 21, 2023
e8ca66d
Logout should be tested too imo
Goose-Of-War Jul 21, 2023
a700413
Logout page modification
Goose-Of-War Jul 21, 2023
9c5c736
How is it bypassing lint?
Goose-Of-War Jul 21, 2023
624792f
That fixes forbidden
Goose-Of-War Jul 21, 2023
7246cb5
Removes some errors
Goose-Of-War Jul 21, 2023
841ec01
Merge pull request #3 from kgpmask/backend
Goose-Of-War Jul 21, 2023
ecb64f0
Contributors: Ankan and Jai
Goose-Of-War Jul 21, 2023
0c215bf
Typo
Goose-Of-War Jul 21, 2023
d0c51b8
shrinkwrap
Goose-Of-War Jul 21, 2023
38df515
Need to make pr
ItsAnkan Jul 21, 2023
b02ee83
Yeet dem test templates
Goose-Of-War Jul 22, 2023
bcd852e
shrinkwrap (fr)
Goose-Of-War Jul 22, 2023
b6cf6bd
Added padding to logo in navbar
SachdevJai Jul 23, 2023
2097eca
Spacing :/
Goose-Of-War Jul 23, 2023
43ed666
Hook router
Goose-Of-War Jul 23, 2023
b09e6d2
Merge pull request #9 from kgpmask/hook
Goose-Of-War Jul 23, 2023
f62609e
Button changes
Goose-Of-War Jul 23, 2023
584c921
Minor tweaks
Goose-Of-War Jul 23, 2023
d24a3c1
Navbar edits
Goose-Of-War Jul 23, 2023
57ec917
Yeeting logout test for now
Goose-Of-War Jul 23, 2023
2e35e32
PR on main == dev. Just remove it ig
Goose-Of-War Jul 23, 2023
368be35
use prevent git-hook GAAH
Goose-Of-War Jul 23, 2023
646ebd4
Test issue :?
Goose-Of-War Jul 23, 2023
b55a57a
Dependency list update
Goose-Of-War Jul 24, 2023
06c62b0
yes yes
ItsAnkan Jul 24, 2023
76c9763
Conflict prevention commit
Goose-Of-War Jul 24, 2023
f55dd7a
hmm
ItsAnkan Jul 24, 2023
c75a5e9
Merge branch 'dev' into admin-portal
ItsAnkan Jul 24, 2023
454162b
admin nav thingy
ItsAnkan Jul 24, 2023
ecb2630
im doing this blindly tbh
ItsAnkan Jul 24, 2023
ad913af
Form support added too
Goose-Of-War Jul 28, 2023
20efef8
Some minor edits
Goose-Of-War Jul 28, 2023
0b71c9c
im back
ItsAnkan Jul 28, 2023
a1b126a
optional password
ItsAnkan Jul 28, 2023
879b7ac
user listing yay
ItsAnkan Jul 29, 2023
dbce504
hmmmm
ItsAnkan Jul 29, 2023
d8a5584
oopsie tee-hee
ItsAnkan Jul 29, 2023
25727d6
Merge pull request #7 from kgpmask/admin-portal
ItsAnkan Jul 29, 2023
9bc3c89
Auth?
Goose-Of-War Jul 30, 2023
bb8e5d4
Admin tests
Goose-Of-War Jul 30, 2023
b392027
Umm... that was silly
Goose-Of-War Jul 31, 2023
3815e35
structur
SachdevJai Aug 3, 2023
56de3c3
added live pages to a separate folder
SachdevJai Aug 3, 2023
1cc9b54
ig this works ?
ItsAnkan Aug 4, 2023
e025d77
stuf
SachdevJai Aug 4, 2023
09c4df7
my work hehehehehehehheheeheheheheheheheheh
ItsAnkan Aug 4, 2023
bd88d79
aaaaaa conflicts
ItsAnkan Aug 5, 2023
1bef2d5
schema changes
ItsAnkan Aug 6, 2023
844842c
timer
SachdevJai Aug 6, 2023
1516582
hmm
ItsAnkan Aug 6, 2023
af82434
Merge branch 'live' of https://github.com/kgpmask/MASK-Event into live
ItsAnkan Aug 6, 2023
cc4b9a2
i hate merge conflicts
ItsAnkan Aug 6, 2023
ba18c55
Merge pull request #10 from kgpmask/docs-update
Goose-Of-War Aug 7, 2023
8e0a82b
socket stuff
SachdevJai Aug 7, 2023
5a4dca2
sockets.js
SachdevJai Aug 7, 2023
3de48f6
added stuff in server.js
SachdevJai Aug 7, 2023
70bec67
some work :)
ItsAnkan Aug 7, 2023
5ed1fee
Just a timer...
Goose-Of-War Aug 8, 2023
d5e2bae
Landing page content
Goose-Of-War Aug 8, 2023
023aab5
Oops JS
Goose-Of-War Aug 8, 2023
0c7a5a5
Location
Goose-Of-War Aug 8, 2023
2e9bd29
Information
Goose-Of-War Aug 8, 2023
6ce7f79
Border animations (blame Bhavesh)
Goose-Of-War Aug 9, 2023
85a4888
Forgot to add this modif
Goose-Of-War Aug 10, 2023
92b7fd8
Please tell me you aren't bypassing this too
Goose-Of-War Aug 10, 2023
f2d99f8
why do i keep postponing to do sockets later ;-;
ItsAnkan Aug 10, 2023
6f8f865
small changes
ItsAnkan Aug 10, 2023
7092435
new Schema
ItsAnkan Aug 10, 2023
45883e7
schema changes again
ItsAnkan Aug 10, 2023
f8ac423
um
SachdevJai Aug 10, 2023
31a7567
soemthing
ItsAnkan Aug 10, 2023
92014f7
Merge branch 'live' of https://github.com/kgpmask/MASK-Event into live
ItsAnkan Aug 10, 2023
c4d5f86
next/prev buttons
SachdevJai Aug 10, 2023
455c3ca
working atleast
ItsAnkan Aug 10, 2023
bbeee48
Merge branch 'live' of https://github.com/kgpmask/MASK-Event into live
ItsAnkan Aug 10, 2023
baa5e95
hmmm
ItsAnkan Aug 10, 2023
d19f95e
questions display now
SachdevJai Aug 10, 2023
c1cac9e
router admin stuf
SachdevJai Aug 10, 2023
5809192
aarghhh
ItsAnkan Aug 10, 2023
5104882
Merge branch 'live' of https://github.com/kgpmask/MASK-Event into live
ItsAnkan Aug 10, 2023
0aabbb2
yes yes yes yes, finally something is happening
ItsAnkan Aug 10, 2023
54eb9fc
this is working finally yay !!!!!!!!
ItsAnkan Aug 10, 2023
2e8f58b
response cache
ItsAnkan Aug 10, 2023
9ae9c69
much frontend
ItsAnkan Aug 11, 2023
cbd9c30
master-frontend
SachdevJai Aug 11, 2023
93ed728
disabled button css
SachdevJai Aug 11, 2023
e53e705
case changes
SachdevJai Aug 11, 2023
1a3992a
Merge pull request #14 from kgpmask/landing-page
Goose-Of-War Aug 12, 2023
f2c278b
Merge pull request #11 from kgpmask/admin-tests
Goose-Of-War Aug 12, 2023
d71dd7b
this is ankan who again forgot his laptop ;-;
Symbiot01 Aug 13, 2023
6e534ef
welp... time's up, i'll now do from my account
Symbiot01 Aug 13, 2023
9e27280
lint :glare:
ItsAnkan Aug 16, 2023
a645a6f
checker.. coming soon tm
ItsAnkan Aug 16, 2023
025dd83
spelcheck and stuf we worked on last week
SachdevJai Aug 16, 2023
b47c545
some changes
ItsAnkan Aug 16, 2023
cc12c46
cheker working yay ! need to make a rechecker ig
ItsAnkan Aug 16, 2023
029de3b
optimisation
ItsAnkan Aug 16, 2023
77afc13
rechecker start
ItsAnkan Aug 17, 2023
3f1b224
Syncing dev changes
Goose-Of-War Aug 18, 2023
9131959
Y'all need to organize your code better
Goose-Of-War Aug 18, 2023
22d2601
redundant checker
ItsAnkan Aug 18, 2023
ae6abd7
ugh
ItsAnkan Aug 18, 2023
f45457d
i messed up ;-;
ItsAnkan Aug 18, 2023
7a4566d
hmm
ItsAnkan Aug 18, 2023
30fe50c
fixes
ItsAnkan Aug 19, 2023
2f5a551
i missed these last commit
ItsAnkan Aug 19, 2023
5ce3ddf
recheck, db modifications, and goos
ItsAnkan Aug 20, 2023
3db14fe
if my pc crashes or dies, do it elsewhere
ItsAnkan Aug 20, 2023
b11c32d
results page final
ItsAnkan Aug 20, 2023
95748c7
Goddamnit Bread Toast
Goose-Of-War Aug 20, 2023
62162f7
username and results
ItsAnkan Aug 22, 2023
6dd0a6f
swap
ItsAnkan Aug 22, 2023
9a51d5e
some frontend
ItsAnkan Aug 22, 2023
052b6bb
results page rework
Sounak990 Aug 25, 2023
96d111e
im sleepy ;-;
Sounak990 Aug 26, 2023
1f11acf
my lappy may be fixed tmw
Sounak990 Aug 27, 2023
441c05b
im back yayyyyy
ItsAnkan Aug 27, 2023
a3c93eb
bren not working sometimes, gomen
ItsAnkan Aug 27, 2023
0fb9e9f
pfp added
Symbiot01 Aug 29, 2023
820988f
pfp added
Symbiot01 Aug 29, 2023
13551e9
just to make sure my pc doesn't crash
ItsAnkan Aug 29, 2023
c0280e7
aaa
ItsAnkan Aug 29, 2023
b4aef36
push
ItsAnkan Aug 30, 2023
5e5d7df
final ig
ItsAnkan Aug 30, 2023
af59122
details width fix
ItsAnkan Aug 30, 2023
6894019
hover stuff
ItsAnkan Aug 30, 2023
1b9fbf3
quiz redirect
ItsAnkan Aug 30, 2023
05ed540
Raman colour change
Goose-Of-War Aug 30, 2023
d3c19ae
Adding info to navbar
Goose-Of-War Aug 30, 2023
753dc14
Merge pull request #13 from kgpmask/live
Goose-Of-War Aug 30, 2023
fb3eafc
Aman credits
Goose-Of-War Aug 30, 2023
dfc7d3d
Version++ (1.0.0)
Goose-Of-War Aug 30, 2023
9043ee2
Navbar fix
Goose-Of-War Aug 30, 2023
6ae1cb8
Please contact the concerned authorities
Goose-Of-War Aug 30, 2023
fdf87f4
Conflict prevention commit
Goose-Of-War Aug 31, 2023
37a4f66
Some tweaks in the template
Goose-Of-War Aug 31, 2023
ae967b4
added information, legend fix for moz, css fix
ItsAnkan Aug 31, 2023
151d0a2
scrollbar
ItsAnkan Aug 31, 2023
243dfa4
css fixes
ItsAnkan Aug 31, 2023
e63e312
Patch work
Goose-Of-War Sep 1, 2023
f1853cb
user image
ItsAnkan Sep 2, 2023
3d05700
Merge branch 'dev' of https://github.com/kgpmask/MASK-Event into dev
ItsAnkan Sep 2, 2023
5b333ea
always scared of my laptop dying ;-;
ItsAnkan Sep 2, 2023
81828a7
Changing the time back to Sep 3 1400 hrs
Goose-Of-War Sep 3, 2023
249f8aa
Team List page for admin and Timeout page done (kinda)
destryptor Mar 1, 2024
ffae772
Admin frontend completed with routes
destryptor Mar 1, 2024
5d3a0ef
Redundant (possibly) validation rules removed
destryptor Mar 1, 2024
fc99f2a
State transition with localStorage complete
destryptor Mar 2, 2024
5f45dcb
State transition fixes and Basic Model creation
destryptor Mar 6, 2024
fdde2ef
removed unused tests
ItsAnkan Mar 7, 2024
2c33811
added a small function to start/end the quiz
ItsAnkan Mar 7, 2024
d41e2ca
localstorage hehe
ItsAnkan Mar 7, 2024
4332bd8
fjbkjdfhasjd
ItsAnkan Mar 8, 2024
33073d4
States fixed yet again (with a bit of localStorage use)
destryptor Mar 8, 2024
e114af4
interface changes
ItsAnkan Mar 9, 2024
4faa332
DB stuff
Goose-Of-War Mar 9, 2024
e272f7c
Auth
Goose-Of-War Mar 9, 2024
7a52175
shrinkwrap mishap
Goose-Of-War Mar 9, 2024
c2e9b5d
Edit and list team work
Goose-Of-War Mar 9, 2024
ec852c1
interface works, almost
ItsAnkan Mar 9, 2024
09d1d46
test
ItsAnkan Mar 9, 2024
fed1621
leaning
ItsAnkan Mar 9, 2024
41fe10f
backen shii
ItsAnkan Mar 9, 2024
00e20a2
Onkon baka
destryptor Mar 9, 2024
7421f07
GIT SUCKS
destryptor Mar 9, 2024
277190d
Onkon lolicon
destryptor Mar 9, 2024
f42e7e0
Onkon in prison
destryptor Mar 9, 2024
63d90ad
Onkon's sentence increased
destryptor Mar 9, 2024
8524f53
Onkon's sentence++
destryptor Mar 9, 2024
180ce33
Onkon's sentence*=2
destryptor Mar 9, 2024
62c394f
why booli ;-;
ItsAnkan Mar 9, 2024
136a33d
nvm i get it ;-;
ItsAnkan Mar 9, 2024
4b71588
i need sleep
ItsAnkan Mar 9, 2024
7c8cb55
Onkon is slowly turning into a mad man
destryptor Mar 9, 2024
b72d2a8
Onkon is slowly turning into a mad man
destryptor Mar 9, 2024
c46b17f
Onkon was whacked by the jail super
destryptor Mar 9, 2024
b2eda3c
Onkon's sentence reduced by half
destryptor Mar 9, 2024
b573bd0
started ???
ItsAnkan Mar 9, 2024
c305abc
Onkon dropped the soap
destryptor Mar 9, 2024
0b40f46
ono
ItsAnkan Mar 9, 2024
0055b0f
didnt knwo she was underaged
ItsAnkan Mar 9, 2024
0e92925
Merge pull request #18 from kgpmask/treasure-hunt
Goose-Of-War Mar 10, 2024
9eec64c
Version++ (1.1.0)
Goose-Of-War Mar 10, 2024
b61307d
Conflict resolution -_-
Goose-Of-War Mar 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/styles/form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ button:hover {
background-color: #c90c0c;
}

button:disabled {
background-color: var(--light-pink);
}

.item {
display: flex;
flex-direction: column;
Expand Down
17 changes: 17 additions & 0 deletions database/Schemas/Location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const mongoose = require('mongoose');

const locationSchema = new mongoose.Schema({
_id: { type: String, required: true },
name: { type: String, required: true },
pointerQuestion: [{ type: String, required: true }],
code: { type: String, required: true },
questions: [
{
question: { type: String, required: true },
answer: { type: Number, required: true }
}
],
keywords: [{ type: String, required: true }]
}, { collection: 'locations' });

module.exports = mongoose.model('Location', locationSchema);
9 changes: 9 additions & 0 deletions database/Schemas/RiddleQuestion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const mongoose = require('mongoose');

const riddleQuestionSchema = new mongoose.Schema({
_id: { type: String, required: true },
question: { type: String, required: true },
answer: { type: String, required: true }
}, { collection: 'riddle-questions' });

module.exports = mongoose.model('RiddleQuestion', riddleQuestionSchema);
27 changes: 27 additions & 0 deletions database/Schemas/Team.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const mongoose = require('mongoose');

const teamSchema = new mongoose.Schema({
_id: { type: Number, required: true },
name: { type: String, required: true },
isAdmin: Boolean,
password: { type: String, requred: true },
members: [
{
name: { type: String, required: true },
email: { type: String, required: true },
phone: { type: String, required: true }
}
],
status: { type: String, required: true },
questionsAttempted: { type: Number, required: true, default: 0 },
order: [
{
location: { type: Number, required: true },
pointer: { type: Number, required: true },
question: { type: Number, required: true }
}
],
timeout: { type: [Date, null] }
}, { collection: 'event-teams' });

module.exports = mongoose.model('Team', teamSchema);
9 changes: 9 additions & 0 deletions database/Schemas/TeamSession.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const mongoose = require('mongoose');

const sessionSchema = new mongoose.Schema({
_id: { type: String, required: true },
teamId: { type: Number, required: true },
timestamp: { type: Date, default: new Date() }
}, { collection: 'team-session' });

module.exports = mongoose.model('TeamSession', sessionSchema);
85 changes: 84 additions & 1 deletion database/handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ const Session = require('./Schemas/Session');
const Questions = require('./Schemas/Questions');
const Records = require('./Schemas/Records');
const Results = require('./Schemas/Results');
// Treasure Hunt stuff
const Location = require('./Schemas/Location');
const Team = require('./Schemas/Team');
const TeamSession = require('./Schemas/TeamSession');

async function createUser (userData) {
const _id = userData.userID ?? (await User.find({ _id: { '$gt': 10000 } })).length + 10001;
Expand Down Expand Up @@ -171,6 +175,76 @@ async function getLiveResults (quizId) {
return await Results.find({ quizId }).lean().sort({ 'points': -1 });
}

// Treasure Hunt Methods

async function getLocations () {
return await Location.find().lean();
}

async function getTeams () {
return await Team.find({ isAdmin: [undefined, false] }).lean();
}

async function getTeamById (_id) {
return await Team.findById(_id);
}

async function validateTeam ({ username: teamId, password }) {
const team = await Team.findById(~~teamId);
if (!team) throw new Error('Team could not be found');
if (team.password === password) return team._id;
else throw new Error('Password does not match');
}

async function updateTeamDetails (ctx) {
const { id, name, members } = ctx;
const team = await Team.findById(id);
team.name = name;
team.members = members;
return await team.save();
}

async function updateTeamStatus (ctx) {
const { _id, status } = ctx;
const team = await Team.findById(_id);
team.status = status;
if (status === 'riddle-timeout') {
team.timeout = new Date(Date.now() + 120 * 1000);
setTimeout(async () => {
team.status = 'riddle-question';
team.timeout = null;
await team.save();
}, 120 * 1000);
} else if (status === 'location-code') {
team.questionsAttempted = ctx.questionNo;
}
return await team.save();
}

async function getTeamFromSessionID (sessionId) {
const session = await TeamSession.findById(sessionId);
const team = await Team.findById(session.teamId);
if (!team) throw new Error('Team Not Found');
else return team;
}

async function createTeamSession (teamId) {
// 3327: You Are My Special
const sessionId = [3, 3, 2, 7].map(i => (Math.random() + 1).toString(36).substring(2, 2 + i)).join('-');
const session = new TeamSession({
_id: sessionId,
teamId: teamId
});
await session.save();
return sessionId;
}

async function removeTeamSession (sessionId) {
// Use this if we want to remove sessions after logout
await Session.findByIdAndDelete(sessionId);
}


module.exports = {
createUser,
editUser,
Expand All @@ -190,5 +264,14 @@ module.exports = {
addLiveRecord,
addLiveResult,
updateLiveResult,
getLiveResults
getLiveResults,
getLocations,
getTeams,
getTeamById,
validateTeam,
updateTeamDetails,
updateTeamStatus,
getTeamFromSessionID,
createTeamSession,
removeTeamSession
};
4 changes: 2 additions & 2 deletions npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mask-event",
"version": "1.0.0",
"version": "1.1.0",
"description": "A lighter site made for events using github.com/kgpmask/MASK as a base",
"main": "src/server.js",
"directories": {
Expand Down
58 changes: 50 additions & 8 deletions routers/admin-router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,67 @@ const dbh = require('../database/handler');
const { body, validationResult } = require('express-validator');
const checkAdmin = require('./check-admin');

const teams = require('../src/samples/teams.json');
const riddleQuestions = require('../src/samples/riddleQuestions.json');

router.use('/', checkAdmin);

router.get('/', (req, res) => {
res.renderFile('admin/_admin.njk');
});

router.get('/edit-team', async (req, res) => {
const teamID = parseInt(req.query.teamID);
const team = await dbh.getTeamById(teamID);
return res.renderFile('admin/team-edit.njk', { team });
});

router.patch('/edit-team', [
body('id')
.isNumeric()
.trim()
.notEmpty().withMessage('No ID Provided'),
body('teamName')
.trim()
.notEmpty().withMessage('No Name Provided')
], async (req, res) => {
const errors = validationResult(req);
if (!errors.isEmpty()) {
const errorMessages = errors.array().map(error => error.msg);
throw new Error(errorMessages[0]);
}
const team = {
id: req.body.id,
name: req.body.teamName,
members: [
{ name: req.body.name1, email: req.body.email1, phone: req.body.phone1 },
{ name: req.body.name2, email: req.body.email2, phone: req.body.phone2 },
{ name: req.body.name3, email: req.body.email3, phone: req.body.phone3 },
{ name: req.body.name4, email: req.body.email4, phone: req.body.phone4 }
].filter(i => i.name)
};
// const teamIndex = teams.findIndex(t => t.id === team.id);
// if (teamIndex === -1) {
// teams.push(team);
// }
await dbh.updateTeamDetails(team);
return res.status(200).send('Edited Successfully');
});


router.get('/list-users', async (req, res) => {
const users = await dbh.getUsers();
res.renderFile('admin/user-list.njk', { users });
});

router.get('/edit-user', async (req, res) => {
const username = req.query.username;
if (!username) return res.redirect('/admin/list-users');
const data = (await dbh.getUserByUsername(username)).toObject();
delete data.salt;
delete data.hash;
res.renderFile('admin/user-edit.njk', { ...data });
});
// router.get('/edit-user', async (req, res) => {
// const username = req.query.username;
// if (!username) return res.redirect('/admin/list-users');
// const data = (await dbh.getUserByUsername(username)).toObject();
// delete data.salt;
// delete data.hash;
// res.renderFile('admin/user-edit.njk', { ...data });
// });

router.patch('/edit-user', [
body('name')
Expand Down
Loading
Loading