Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Send welcome email after verification email #192

Open
wants to merge 162 commits into
base: prod
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
70eb63c
created welcome and actions page for player
mnarayan1 Sep 4, 2021
ed3c574
added voter registration page
mnarayan1 Sep 4, 2021
7a51e8b
player goes to rock the vote of login
mnarayan1 Sep 5, 2021
bb46f74
player goes to rock the vote or login
mnarayan1 Sep 5, 2021
f6685ac
Merge branch 'development' of https://github.com/mnarayan1/frontend i…
mnarayan1 Sep 10, 2021
69c6be4
added basic styling to player pages
mnarayan1 Sep 10, 2021
26705b3
fixed routing
mnarayan1 Sep 10, 2021
f4e71fa
fixed component error
Devanshusp Sep 14, 2021
15d17d7
Merge branch '8by8-org:development' into development
Devanshusp Sep 14, 2021
bf5dc29
made header fixed and adjusted navbar animation
Devanshusp Sep 18, 2021
f6c8388
merge conflict
Devanshusp Sep 18, 2021
5b8cfb4
fixed header spacing error
Devanshusp Sep 18, 2021
fa47b81
added scss styles folder
Devanshusp Sep 18, 2021
0adfd9e
added /challengerwelcome page
Devanshusp Sep 18, 2021
f89b5b3
Merge branch 'development' into development
mnarayan1 Sep 25, 2021
f1cdb65
moved styles folder out of components folder
Devanshusp Oct 1, 2021
9b804a0
added files in styles folder
Devanshusp Oct 1, 2021
76e8863
Merge pull request #35 from Devanshusp/development
Devanshusp Oct 1, 2021
930a5ba
added election reminders and challenge for player
mnarayan1 Oct 5, 2021
a704c3a
Fixed merge conflicts
kphan20 Oct 7, 2021
55d2110
Merge branch '8by8-org-development' into development after merge
kphan20 Oct 7, 2021
8640d63
Added PrivateRoute to progress page
kphan20 Oct 7, 2021
ea387ea
Added avatar image specifications and resolves sass merge conflict
kphan20 Oct 7, 2021
d6bc465
Added another test badge
kphan20 Oct 7, 2021
0be6fcb
cleaned up unused challenge page and renamed avatars
Devanshusp Oct 10, 2021
985ecaf
Merge pull request #34 from kphan20/development
Devanshusp Oct 10, 2021
31fa5ab
integrate RTV Election Reminder form (#46)
dvorakjt Oct 12, 2021
f0ca7ba
removed previously deleted component not found
Devanshusp Oct 12, 2021
292c97c
changed assets folder stucture
Devanshusp Oct 16, 2021
162da7e
added font and button styles
Devanshusp Oct 17, 2021
e795fe2
updated /homepage design
Devanshusp Oct 17, 2021
7ad0cbf
fixed svg spacing
Devanshusp Oct 18, 2021
1d02fc1
added footer with social media links
Devanshusp Oct 18, 2021
04effcc
cursor pointer on footer icon hover
Devanshusp Oct 18, 2021
23bb164
player redirected to action after login
mnarayan1 Oct 23, 2021
e6ee9b2
Updated styling on /homepage + added footer (#48)
Devanshusp Oct 23, 2021
0502465
fixed issues
mnarayan1 Oct 23, 2021
2609c27
uncommented homepage scss file
Devanshusp Oct 29, 2021
fd959ac
typo
Devanshusp Oct 29, 2021
b8756a3
fixed merge conflicts
Devanshusp Oct 29, 2021
1320bd3
Merge branch 'mnarayan1-development' into development
Devanshusp Oct 29, 2021
5b36471
Merge branch 'development' into development
Devanshusp Oct 29, 2021
e069eb4
Merge pull request #1 from 8by8-org/development
Devanshusp Oct 29, 2021
469eaa5
Task 1.6, Task 4.2, Task 0.2 (#32)
arniber21 Nov 9, 2021
6c6b30e
Create pr_template.md
rickyyx Nov 9, 2021
83928a1
Rename pr_template.md to pull_request_template.md
rickyyx Nov 9, 2021
4b04249
styling player flow
mnarayan1 Nov 13, 2021
9fa955d
sign up links added
mnarayan1 Nov 13, 2021
517ef4b
fixes
mnarayan1 Nov 20, 2021
ce5519f
fixed action message and reminder path
mnarayan1 Dec 4, 2021
1742046
added sharing functionality
Devanshusp Dec 11, 2021
4985c17
Merge branch 'development' of https://github.com/Devanshusp/frontend …
Devanshusp Dec 11, 2021
879961e
added styling and images
Devanshusp Dec 11, 2021
1ccbefd
1.2 & 3.1: redirection and styling for player flow (#60)
mnarayan1 Dec 11, 2021
0f4dcf2
Merge branch '8by8-org:development' into development
mnarayan1 Dec 18, 2021
c975c9d
Use Button again for button components (#65)
rickyyx Dec 19, 2021
22cca91
Merge branch '8by8-org:development' into development
mnarayan1 Dec 19, 2021
1dad61f
generate url
mnarayan1 Dec 21, 2021
b2bd0f5
merge confilcts
Devanshusp Dec 29, 2021
0c0da81
Merge pull request #3 from Devanshusp/8by8-org-development
Devanshusp Dec 29, 2021
0a85a7d
get challenger info from url
mnarayan1 Jan 2, 2022
b8bda6d
Task 2.3: Link Sharing (#64)
Devanshusp Jan 10, 2022
0504145
Task 4.3 (#63)
dvorakjt Jan 10, 2022
e2f1a0b
link generation, redirection
mnarayan1 Jan 17, 2022
e84e1f4
Merge branch '8by8-org:development' into development
Devanshusp Jan 24, 2022
f431f51
added google recaptcha to signup
Devanshusp Jan 24, 2022
b1c1dfe
added recaptcha to signin
Devanshusp Jan 29, 2022
fbb3012
autoselect first avatar on signup
Devanshusp Jan 29, 2022
4ac5e56
link sharing with generated url
mnarayan1 Feb 4, 2022
695516f
Small Bug Fixes (#68)
arniber21 Feb 12, 2022
33156bf
fixed conflicts from merge
Devanshusp Feb 12, 2022
9f12c32
Added Google ReCAPTCHA + Fixed avatar autoselect bug (#69)
Devanshusp Feb 12, 2022
84477e6
styling for challenger welcome + bug fixes
Devanshusp Feb 15, 2022
9a10840
Merge branch '8by8-org:development' into development
Devanshusp Feb 15, 2022
369155e
Merge branch 'development' into development
mnarayan1 Feb 15, 2022
a9e00f8
Revert "3.2: create sharing link and extract challenger info from lin…
mnarayan1 Feb 15, 2022
a2de85c
Merge branch '8by8-org:development' into development
Devanshusp Feb 18, 2022
9401a99
firestore saves names and avatars on signup
Devanshusp Feb 18, 2022
cf98a22
properly adding name + avatar on signup
Devanshusp Feb 18, 2022
8457b0b
added firebase cloud function (needs testing) + signup styling
Devanshusp Feb 18, 2022
8c087c5
Voter Registration Feature UI (#81)
dvorakjt Feb 25, 2022
2453987
added styling files + progress page
Devanshusp Mar 4, 2022
8302689
progress page functionality & styling
Devanshusp Mar 4, 2022
e0cec36
merge conflicts
Devanshusp Mar 5, 2022
5005464
Update README.md
rickyyx Mar 5, 2022
6e7b631
added env file to hide api keys
Devanshusp Mar 12, 2022
84ba3b4
Added Badges in /Progress page + Emailing + Styling & Bugs (#92)
Devanshusp Mar 17, 2022
08ee7cc
Update firebase install instructions (#100)
wcouturiaux Mar 27, 2022
de812e6
3.2 link sharing update (#96)
mnarayan1 Apr 2, 2022
256345d
added api keys doc to readme
Devanshusp Apr 6, 2022
4ab6d9f
Update Header #87
MazharulIslam-Naim Apr 9, 2022
1c6c0b9
Update Header #87 (#106)
MazharulIslam-Naim Apr 12, 2022
b5504ab
Link update, minor styling fixes (#107)
mnarayan1 Apr 12, 2022
3b413a1
Issue #70, IG and SMS Invite/Share workflow (#105)
ty730 Apr 12, 2022
f47102e
Min width to 375px
Devanshusp Apr 12, 2022
a872bc8
challenger finishes/fails challenge
Devanshusp Apr 12, 2022
dc0fd5f
confetti animation on /actions
Devanshusp Apr 12, 2022
cbfb1b0
header icon margin
Devanshusp Apr 12, 2022
67f511b
user type (unfinished)
Devanshusp Apr 12, 2022
1d056fd
merge conflicts
Devanshusp Apr 12, 2022
9646654
styling
Devanshusp Apr 12, 2022
880bb1a
Fixed styling turning header text black (#111)
ty730 Apr 13, 2022
7e319e6
button change in /progress
Devanshusp Apr 14, 2022
8a2ae5f
fixed merge conflicts
Devanshusp Apr 15, 2022
adfdf94
[icon] Fix some icon and preview messages for the website (#110)
rickyyx Apr 15, 2022
0a85b2d
merge conflicts
Devanshusp Apr 15, 2022
3081519
Merge pull request #3 from Devanshusp/8by8-org-development
Devanshusp Apr 15, 2022
f992009
Merge branch '8by8-org:development' into development
Devanshusp Apr 15, 2022
27af60f
NaN Days Left issue fix + getUserType function
Devanshusp Apr 19, 2022
0520b40
Merge branch 'Devanshusp-development' into development
Devanshusp Apr 19, 2022
e38afa7
Issues 89 (complete) and 97 (partially complete) - Styling and comple…
dvorakjt Apr 23, 2022
e1d6817
Issue #97 Partial Completion (#104)
wcouturiaux Apr 27, 2022
2858894
Merge branch 'development' into development
MazharulIslam-Naim May 2, 2022
6ab8b38
#102 Add better loading prompt on progress (#114)
mnarayan1 May 3, 2022
0a17948
Make avatar state controlled (#118)
wcouturiaux May 3, 2022
34ab4bd
Updates to Frontend Field Validation - Register to Vote Flow (#120)
dvorakjt May 4, 2022
06b9b86
Add completedAction for challenger sharing on IG (#121)
wcouturiaux May 4, 2022
4c60941
Update pull_request_template.md
Devanshusp May 6, 2022
1ed868c
added emailing for players and challengers (#119)
Devanshusp May 10, 2022
be3b106
Update /actions page #75 (Partial) (#123)
MazharulIslam-Naim May 11, 2022
c544131
Player can become a challenger (#129)
mnarayan1 May 19, 2022
015aa6d
Add files via upload (#132)
CaptainExtremis May 22, 2022
a90a382
Change default select for party and race, unauthenticated users redir…
mnarayan1 May 23, 2022
3317d22
Register to Vote Issues (#134)
dvorakjt May 24, 2022
3b58995
Styling + Dynamic Sidebar + Legal Pages (tos, privacy policy) (#135)
Devanshusp May 24, 2022
a29e2a8
Update /actions page #75 (Finish): Added in share. (#130)
MazharulIslam-Naim May 25, 2022
a7d9af8
Remove FB/Messenger sharing icons && fix privacy policy link in sign-…
rickyyx May 25, 2022
01fea32
Minor styling bug fixes (#138)
Devanshusp May 25, 2022
97bb4cf
Fixed wrong logo file name in manifest and index.html. Added alt prop…
MazharulIslam-Naim May 26, 2022
34db675
Fix election reminders loop bug (#139)
dvorakjt May 26, 2022
7348868
[PR1] Change "Go to Instagram" button, remove "8by8/" (#141)
CaptainExtremis Jun 4, 2022
26d996e
Bug fixes. (#140)
MazharulIslam-Naim Jun 6, 2022
4643df6
Fix Underline Issue #122 (#143)
arniber21 Jun 7, 2022
10624da
Design Fixes (#142)
MazharulIslam-Naim Jun 10, 2022
1239ca0
Change margin of Election Alerts page. Change link styles to bold and…
zjiao19 Jun 19, 2022
862ae01
Copy Notification (#146)
Devanshusp Jun 24, 2022
4b890dc
Made preview responsive and look more like designs. Added in challeng…
MazharulIslam-Naim Jul 2, 2022
5c22e1b
Tech-Design UX Walkthrough Item 9 partial (#147)
wcouturiaux Jul 7, 2022
0ae281d
Removed meta tags from index.html and added them individually to each…
MazharulIslam-Naim Jul 16, 2022
727c245
Revert "Removed meta tags from index.html and added them individually…
MazharulIslam-Naim Jul 21, 2022
e1a3570
Organize Folders, issue #116 (#144)
arniber21 Jul 21, 2022
279c1d3
jumping (#156)
projectr495836 Aug 3, 2022
823d676
Fixed a lot of the console errors and warnings. (#170)
MazharulIslam-Naim Aug 3, 2022
a0e0517
Built a page, added links and new info (#171)
rajnawal Aug 6, 2022
ef29490
Issue #155 - Add Address Validation to Voter Reg Address Form (#173)
dvorakjt Aug 13, 2022
bd2e3e7
Partner database functions (#175)
MazharulIslam-Naim Aug 13, 2022
95d880b
Issue 165, US4.2: Build /rewards page; Issue 167, US 6.1/8.1: Build /…
arniber21 Aug 23, 2022
c7e1841
Save voter registration data in Firebase (#176)
zjiao19 Aug 23, 2022
1ced56d
Iss158 update vote reg comp (#178)
wcouturiaux Aug 31, 2022
33f99b4
Update /actions and address error handling (#179)
dvorakjt Sep 3, 2022
064fc46
Worked on Issue 8.1 (#182)
rajnawal Sep 5, 2022
c671cb9
Email verification (#181)
Devanshusp Sep 5, 2022
e838046
Revert Actions, Progress and Welcome pages to Alpha if no partners ex…
dvorakjt Sep 14, 2022
9df48e2
Update challenge won email for issue #168 (#186)
ty730 Sep 14, 2022
1b26f19
Update Rewards Page with Current Partners (#188)
dvorakjt Sep 14, 2022
c0b14b7
Fix Potential Security Issue with Voter Registration Data (#189)
dvorakjt Sep 15, 2022
c87eb74
Send welcome email after email verification (#191)
ty730 Sep 18, 2022
92abc20
Made changes to the choose rewards flow (#193)
rajnawal Sep 20, 2022
b188ac5
Promisify Firebase Https Functions, link Voter Reg FormCompleted page…
dvorakjt Sep 24, 2022
a132a59
Added Google analytics. (#197)
MazharulIslam-Naim Feb 15, 2023
3124575
Fix to a bunch of ESLint warnings. (#200)
MazharulIslam-Naim Mar 23, 2023
ecdb5a6
Fixed more console warnings. (#202)
MazharulIslam-Naim Apr 5, 2023
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
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REACT_APP_FIREBASE = apikey

18 changes: 18 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Overview
> REQUIRED
> Fill in the overview of this PR, what this PR is trying to achieve




## Test Plan
> REQUIRED
> What you did to verify your PR works as claimed? Make sure to list **things/steps/screenshots/screentcasts** so that others could reproduce your test easily. Share styling changes and component updates through screenshots





## Follow ups
> It is okay for the PR to be not perfect, list what you/other should work on after this PR is merged

6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# testing
/coverage


# production
/build

Expand All @@ -17,7 +18,12 @@
.env.development.local
.env.test.local
.env.production.local
.env

npm-debug.log*
yarn-debug.log*
yarn-error.log*

*.code-workspace

.idea/
8 changes: 8 additions & 0 deletions .idea/.gitignore

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

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

9 changes: 9 additions & 0 deletions .idea/web-app.iml

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

2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Have the following installed before you proceed:
- NodeJS, preferably v12 and above
- Ensure you can run `node --version` and `npm --version` in a terminal without a problem
- `firebase-cli`
- install by running `npm install -g firebase-cli`
- install by running `npm install -g firebase-tools`

After you have satisfied the above installation requirements, run `firebase login` and login with the Google account that I added to the firebase project.

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
# 8by8 web app

## Short note

The "me" in all of these documentation files is referring to "Simon Cheng."

## First time developers

Expand All @@ -18,6 +15,7 @@ Read the [CONTRIBUTING.md](CONTRIBUTING.md) file for how to get started on contr
- [Tech meet notes folder](https://drive.google.com/drive/folders/16GFweS5XBMkJ-U1t1mUzzOLJjbMmx4o7)
- [Engineering team planner](https://docs.google.com/document/d/1_WZn11hIymzSd0zRWT1iZlIP8ILUxasaGWlsEAtsG30/edit)
- [Data schema](https://docs.google.com/document/d/1IUDqY38GozFuU9b766OL7mhGuWvkcZF3WX7oc0OQnMc/edit)
- [API Keys Document](https://docs.google.com/document/d/1OHcXlCUHmDBVPOpLTvSkm1uh0ff1QWzLEd3SDHN9HOI/edit)
- Other resources
- [8by8 trello board](https://trello.com/b/SbQIdVFR/8by8-all-team)

Expand Down
1 change: 1 addition & 0 deletions functions/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ module.exports = {
},
parserOptions: {
ecmaVersion: 8,
sourceType: "module",
},
};
200 changes: 157 additions & 43 deletions functions/index.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,167 @@
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const fetch = require("node-fetch");
const FormData = require("form-data");

admin.initializeApp();

const db = admin.firestore();

// signup function
exports.onSignup = functions.auth.user().onCreate(async (user) => {
async function generateUniqueInviteCode() {
const length = 8;
const dictionary = "234579abcdefghjkmnpqrstwxyz"; // unambiguous characters

const generateRandom = () => {
let out = "";
for (let i = 0; i < length; i++) {
out += dictionary.charAt(Math.floor(Math.random() * dictionary.length));
}
return out;
};
const checkIsRandom = (allegedRandom) => { // dumbest way of guaranteeing uniqueness but this will have to do for now
return new Promise((resolve, reject) => {
db.collection("users").where("inviteCode", "==", allegedRandom)
.get()
.then(querySnapshot => resolve(querySnapshot.empty))
.catch(reject);
});
};

let currentRandom = generateRandom();
let timesRegenerated = 0;
while (!await checkIsRandom(currentRandom)) {
currentRandom = generateRandom();
if (++timesRegenerated >= 20) { // terminate before we drain away our resources
throw new Error("either by chance or something really bad happened, but 20 generated invite codes and still yielded no unique code");
}
}
if (timesRegenerated) {
functions.logger.warn(`encountered ${timesRegenerated} collisions`);
}
return currentRandom;
}
const userRef = db.collection("users").doc(user.uid);
if (!(await userRef.get().exists)) {
userRef.set({
email: user.email,
name: "",
avatar: "",
invitedBy: "",
accountCreated: admin.firestore.FieldValue.serverTimestamp(),
notifyElectionReminders: false,
isRegisteredVoter: false,
startedChallenge: false,
sharedChallenge: false,
completedActionForChallenger: false,
challengeEndDate: "",
badges: [],
voteInfo: {},
});
}
});

// verificaition email
exports.sendVerification = functions.auth.user().onCreate((user) => {
const email = user.email;
sendVerificationEmail(email, "verification");
});

// resend verification email
exports.resendVerification = functions.https.onCall((email) => {
return new Promise((resolve, reject) => {
sendVerificationEmailWithPromise(email, "verification").then(() => {
resolve();
}).catch((error) => {
console.log(error);
console.log("Email address provided was: " + email);
reject(new functions.https.HttpsError("unknown", error.message));
});
});
});

// sign in email
exports.sendSigninEmail = functions.https.onCall((email) => {
return new Promise((resolve, reject) => {
sendVerificationEmailWithPromise(email, "sign in").then(() => {
resolve();
}).catch((error) => {
console.log(error);
console.log("Email address provided was: " + email);
reject(new functions.https.HttpsError("unknown", error.message));
});
});
});

function sendVerificationEmail(email, type) {
let test = false;
let actionUrl = "https://challenge.8by8.us/signin";
// uncomment when testing
//test = true;
if (test) {
actionUrl = "http://localhost:3000/signin";
}

const actionCodeSettings = {
url: actionUrl,
handleCodeInApp: true,
};
if (type === "verification") {
admin
.auth()
.generateEmailVerificationLink(email, actionCodeSettings)
.then((link) => {
const URL = "https://usvotes-6vsnwycl4q-uw.a.run.app/email/";
let formData = new FormData();
formData.append("email", email);
formData.append("type", "verifyEmail");
formData.append("verifyLink", link);
fetch(URL, {
method: "POST",
body: formData,
});
});
} else if (type === "sign in") {
admin
.auth()
.generateSignInWithEmailLink(email, actionCodeSettings)
.then((link) => {
const URL = "https://usvotes-6vsnwycl4q-uw.a.run.app/email/";
let formData = new FormData();
formData.append("email", email);
formData.append("type", "verifyEmail");
formData.append("verifyLink", link);
fetch(URL, {
method: "POST",
body: formData,
});
});
}
}

const userRef = db.collection("users").doc(user.uid);
if (!await userRef.get().exists) {
userRef.set({
email: user.email,
name: user.displayName,
inviteCode: await generateUniqueInviteCode(),
isRegisteredVoter: false,
lastActive: admin.firestore.FieldValue.serverTimestamp()
function sendVerificationEmailWithPromise(email, type) {
return new Promise((resolve, reject) => {
let test = false;
let actionUrl = "https://challenge.8by8.us/signin";
// uncomment when testing
//test = true;
if (test) {
actionUrl = "http://localhost:3000/signin";
}

const actionCodeSettings = {
url: actionUrl,
handleCodeInApp: true,
};
if (type === "verification") {
admin
.auth()
.generateEmailVerificationLink(email, actionCodeSettings)
.then((link) => {
const URL = "https://usvotes-6vsnwycl4q-uw.a.run.app/email/";
let formData = new FormData();
formData.append("email", email);
formData.append("type", "verifyEmail");
formData.append("verifyLink", link);
fetch(URL, {
method: "POST",
body: formData,
}).then(() => {
resolve();
}).catch((error) => {
reject(error);
})
}).catch((error) => {
reject(error);
});
} else if (type === "sign in") {
admin
.auth()
.generateSignInWithEmailLink(email, actionCodeSettings)
.then((link) => {
const URL = "https://usvotes-6vsnwycl4q-uw.a.run.app/email/";
let formData = new FormData();
formData.append("email", email);
formData.append("type", "verifyEmail");
formData.append("verifyLink", link);
fetch(URL, {
method: "POST",
body: formData,
}).then(() => {
resolve();
}).catch((error) => {
reject(error);
});
}).catch((error) => {
reject(error);
});
}
});
});
}
Loading