Skip to content
This repository has been archived by the owner on Nov 10, 2019. It is now read-only.
Terrance Li edited this page Sep 24, 2019 · 6 revisions

This is the portal app for Cal Hacks 5.0.

Onboarding

Prerequisites

  • Node.js (^10.16.3)
  • NPM (^6.11.3)

Clone the repository

git clone [email protected]:calhacks/portal.git

Install dependencies

Run npm install or npm i in the repo directory.

Create environment file(s)

Ask an existing tech team member to send you the environment variables. Create a new file named .env in the repo's root directory, and paste the environment variables there.

The app requires the following environment variables:

  • DB_USER: a MySQL username
  • DB_PASSWD: a MySQL password
  • DB_NAME: the name of the database
  • DB_HOST: the hostname of the database
  • SENDGRID_APIKEY: a valid SendGrid API key
  • NODE_ENV: 'production', 'development', etc. (optional)
  • PORT: required for production, otherwise useless

NOTE: It looks like Sequelize isn't playing well with MySQL 8's secure authentication protocol. The fix is to switch to legacy authentication (easy to configure with the MySQL prefPane on Mac); branches dev and feature/error-handling are up-to-date with this change.

Development

Run ./scripts/dev.sh to start running the application on your machine; it will start running on localhost:8000.

Production

We have a CI/CD pipeline in place that will autodeploy the application on push to master. To deploy manually...

  1. SSH into the DigitalOcean droplet
  2. cd portal/
  3. git pull
  4. yarn build

NOTE: There is no need to yarn start as the existing server will reload upon changes to the built files. If the server hasn't started, you can start it in a tmux session:

  1. tmux -s new production
  2. yarn start
  3. Ctrl-B + d (to detach from the tmux session)

Application

Routes

The routes and their handlers are described in src/router/routes.js.

  • /: A link to a homepage, if necessary. It could also just redirect to /login.
  • /login: A login page. User needs to input email and password.
  • /signup: A signup page. User needs to give their first name, last name, email and password.
  • /logout: Ends the user's login session.
  • /dashboard: The user's dashboard. It links to the application questions; there's also a separate tab for choosing/creating a team.
  • /application: Application questions. They auto-fill with information that the user has entered.

Email verification

For a user to sign up, they need to verify their email. When they sign up they'll get an email that takes them to https://2018.calhacks.io/verify?code=XXXXXX. Replacing https://2018.calhacks.io with http://localhost:8000 will run the email verification locally so your test user can login.

Policies

In order to standardize authentication and email verification checks throughout the app, some routes have associated policies that run as middleware, to make sure unauthenticated/unverified users can't access any dashboard, application, or team pages. The routes and policies are described in src/policies/index.js.

The current ones are:

  • authenticateUser(roles): make sure a user is signed in as one of the roles in roles before allowing them to visit the route.
  • emailVerify: make sure a user has verified their email before allowing them to visit the route.

Todos

There's still a lot to be done:

  • Styling pages ✅
  • Post-acceptance stuff (RSVP, travel reimbursement, and logistics) ❗
  • Sponsor portal/admin portal
  • Deploying to werewolves properly ✅
  • Setting up automatic deployment from master and dev
  • Testing app ✅