Fais tes choix sur theodercafe.com
cd backend && cp .env.dev.dist .env.dev && cd ..
docker-compose up
cd frontend
cp .env.dist .env
npm install
npm run start
Authentication is performed via Google OAuth (see Authentication Flow schema below). To use OAuth locally, you need to:
- create a new project on google cloud console or use an existing one
- in the Credential Service create OAuth Client ID credentials with params
- Application type : "Web application"
- Authorized JavaScript origins: http://localhost:3000
- Authorized redirect URIs: http://localhost:8080/auth/google/callback
- copy
Client ID
andClient secret
and paste them inGOOGLE_OAUTH2_CLIENT_ID
andGOOGLE_OAUTH2_CLIENT_SECRET
variables in your.env.dev
file
Help: passport-google-oauth20 library
Login from the frontend: http://localhost:3000/login
.
Connect to database :
docker-compose exec postgresql psql -d theodercafe -U the
UPDATE "users" SET "isAdmin"=true;
You should be able to see http://localhost:3000/admin#/questions page.
Add questions from frontend with the '+' button on bottom right.
From the admin panel, mark them as Validated for asakai
.
Toggle Live Mode : you should see an asakai set with validated questions.
Asakai Mode provides a new set quesitons every day. These quesitions are randomly chosen among "validated questions".
It is also named Live Mode
because you can see others choices live.
You can mark a question as Validated for Asakai
from the admin panel.
The Asakai Set also depends of the Question Set
chosen by the user.
An admin may click changeTodaySet
button to renew the Asakai Set.
On the admin panel, mark a question as Classic
: the question will necessary be part of the Live Mode
set.
Turning on Coach Mode
enables a coach to ask the questions to a brand new Theodoer. Indeed, it will:
- prevent from attaching the choices to the coach's account
- propose an email form at the end of the questioning to register the new Theodoer. If the email does not exist yet:
- a new user is created
- a welcome email is sent
- choices made during asakai and also asakai alterodo result are attached to the new user
If you Toggle Live Mode
to OFF, you may filter questions with the FILTRES menu.
- Dev:
docker-compose exec postgresql psql -d theodercafe -U the
- Prod
PGDATABASE=theodercafe gcloud sql connect theodercafe --user=the
Diagram here https://dbdiagram.io/d/63c40a1b296d97641d79bfe7.
Dump:
docker-compose exec postgresql pg_dump -d theodercafe -U the -s >schema.sql
To run Live Mode features locally, you need to :
-
add a firebase project
-
enable
Firestore Database
on this project. -
in the project settings -> service accounts, create a Firebase Admin SDK
- copy the firebase service account email and paste it into the
FIREBASE_SERVICE_ACCOUNT_CLIENT_EMAIL
variable of your .env.dev - Generate a new private key and paste the
secret_key
value into variable. For example:
FIREBASE_SERVICE_ACCOUNT_CLIENT_EMAIL="[email protected]" FIREBASE_SERVICE_ACCOUNT_PRIVATE_KEY='-----BEGIN PRIVATE KEY-----\nMIIEuaIBADANBgkq...\n-----END PRIVATE KEY-----\n'
- copy the firebase service account email and paste it into the
-
in the Cloud Firestore -> Rules, paste the following rules. It allows any authenticated to read other users' answers. But a user may only modify the answer corresponding to its
userId
.rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { match /questioning/{questioningId}/questions/{questionId}/users/{userId}{ allow write: if request.auth != null && request.auth.uid == userId; } match /questioning/{questioningId}/questions/{questionId}/{users=**}{ allow read: if request.auth != null; } } }