Overview

HTTPS SSH

-:||----||:- Sportsgeist

Credits

The authorization implementationn is taken from the PhoenixGuardian project by Hassox.

Getting ready

To start your Phoenix app:

  • Install dependencies with mix deps.get
  • Create and migrate your database with mix ecto.create && mix ecto.migrate
  • Install Node.js dependencies with npm install
  • Start Phoenix endpoint with mix phoenix.server

Now you can visit localhost:4000 from your browser.

Ready to run in production? Please check our deployment guides.

Learn more

Infrastructure

  • Development:
  • build status Build Status,
  • Code Coverage Coverage Status

Development

Start database container:

docker run --name sportsgeist-postgres -e POSTGRES_PASSWORD=<password> -p 5432:5432 -d postgres

or if already created

docker start sportsgeist-postgres

open a shell inside the container:

docker exec  -it "sportsgeist-postgres"  bash

#or run psql client immediatly
docker exec  -it "sportsgeist-postgres"  psql -U postgres

Use docker-compose

# create new image(s)
docker-compose build

# run in foreground
docker-compose up

dev notes

Testing

Run single test

run single test (eg.):

mix test test/controllers/course_controller_test.exs:67

Debugging a single test

> MIX_ENV=test iex -S mix

in iex setup debugger

:debugger.start
:int.ni(Sportsgeist)
:int.ni(Sportsgeist.CourseController)
:int.ni(Sportsgeist.Course)
:int.break(Sportsgeist.CourseController, 114)

run the tests

Mix.Task.run "test"
select * from accounts where password_hash = crypt('mypassword', password_hash);
//(note how the existing hash is used as its own individualized salt)

Create a hash of :password with a great random salt:

insert into accounts (password) values crypt('mypassword', gen_salt('bf', 8));
//(the 8 is the work factor)
  • apt install libpq-dev
  • cd pg_config --sharedir
  • echo "create extension pgcrypto" | psql -d sportsgeist_dev

Ecto.Adapters.SQL.query(Sportsgeist.Repo, "select * from users where password = crypt($1, password)",["mypassword"])