-
Notifications
You must be signed in to change notification settings - Fork 1
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
HackCamp Whitelist Work Around #516
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
dbf60d3
Merge pull request #496 from nwplus/dev
meleongg 00e9cfa
Merge pull request #499 from nwplus/dev
meleongg 850e7fc
Merge pull request #503 from nwplus/dev
michelleykim 900733e
Merge pull request #505 from nwplus/dev
meleongg e6f57ad
Merge pull request #509 from nwplus/dev
sidyakinian 43e92d1
Merge pull request #513 from nwplus/dev
meleongg 5c5b697
Added Whitelist work around to add hackers to HackCamp
meleongg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import React from 'react' | ||
import { Button } from '../components/Input' | ||
import { setWhitelist } from '../utility/firebase' | ||
|
||
export default () => { | ||
return ( | ||
<div> | ||
<Button | ||
color="secondary" | ||
width="flex" | ||
onClick={() => { | ||
setWhitelist() | ||
}} | ||
> | ||
Add current whitelist | ||
</Button> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import 'firebase/analytics' | ||
import firebase from 'firebase/app' | ||
import 'firebase/firestore' | ||
import 'firebase/analytics' | ||
import 'firebase/storage' | ||
import { | ||
HACKER_APPLICATION_TEMPLATE, | ||
REDIRECT_STATUS, | ||
DB_COLLECTION, | ||
ANALYTICS_EVENTS, | ||
APPLICATION_STATUS, | ||
DB_COLLECTION, | ||
DB_HACKATHON, | ||
ANALYTICS_EVENTS, | ||
HACKER_APPLICATION_TEMPLATE, | ||
REDIRECT_STATUS, | ||
} from '../utility/Constants' | ||
|
||
if (!firebase.apps.length) { | ||
|
@@ -42,6 +42,49 @@ export const getLivesiteDoc = callback => { | |
}) | ||
} | ||
|
||
// ----------------------------------------------------- | ||
// TODO: Delete temporary code that whitelists users that have RSVP'd (all the commented bars) | ||
export const setWhitelist = async () => { | ||
let batch = db.batch() | ||
|
||
let whitelistedArr = [ | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
'[email protected]', | ||
] | ||
|
||
for (let i = 0; i < whitelistedArr.length; i++) { | ||
batch.set( | ||
db.collection(DB_COLLECTION).doc(DB_HACKATHON).collection('Whitelist').doc(whitelistedArr[i]), | ||
{} | ||
) | ||
} | ||
|
||
batch.commit().then(() => { | ||
alert('uploaded successfully') | ||
}) | ||
} | ||
// ----------------------------------------------------- | ||
|
||
// ----------------------------------------------------- | ||
export const getWhitelisted = async () => { | ||
// db.collection('Hackathons').doc('HackCamp2023').collection('Whitelist') | ||
const whitelisted = [] | ||
await db | ||
.collection(DB_COLLECTION) | ||
.doc(DB_HACKATHON) | ||
.collection('Whitelist') | ||
.get() | ||
.then(querySnapshot => { | ||
querySnapshot.forEach(doc => { | ||
whitelisted.push(doc.id) | ||
}) | ||
}) | ||
return whitelisted | ||
} | ||
// ----------------------------------------------------- | ||
|
||
const createNewApplication = async user => { | ||
analytics.logEvent(ANALYTICS_EVENTS.signup, { userId: user.uid }) | ||
const userId = { | ||
|
@@ -82,6 +125,23 @@ const createNewApplication = async user => { | |
...judging, | ||
} | ||
|
||
// ----------------------------------------------------- | ||
// If not whitelisted, no | ||
const whitelisted = await getWhitelisted() | ||
if (whitelisted.includes(user.email)) { | ||
// good to go | ||
newApplication = { | ||
...newApplication, | ||
status: { | ||
applicationStatus: 'acceptedAndAttending', | ||
responded: true, | ||
attending: true, | ||
}, | ||
} | ||
// else, the default application template will block them from submissions -> redirect to "Applications for this hackathon are closed" | ||
} | ||
// ----------------------------------------------------- | ||
|
||
await applicantsRef.doc(user.uid).set(newApplication) | ||
} | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These emails will have to be the actual hacker emails when pushing to prod