Install Docker & Docker-Compose
Before launch the server, you need to connect an SMTP
account if you don't have one you can by example use gmail
go to the .env
file and change all the value with SMTP
ADRESS_SMTP
It's the adresse email you usingPASSWORD_SMTP
It's your passwordRELAY_SMTP
It's your relay, example if you use a gmail account, it's will be smtp.gmail.com
Of course you're not obligated to use a gmail account
If your values SMTP are corrects it's possible the link still don't work because you have the connexion refused
you just need to change in your account the setting Allow applications with less security
if something with the SMTP goes wrong the server will not launch so if the server is launch or pass the test don't worry it's working
Go to the root where the
docker-compose
is and do: sudo docker-compose up
sudo is needed to access to the port
In the terminal where you launch the docker-compose you should see
something like that if all work :
Rocket has launched from http://0.0.0.0:8000
Just go in the direction given on the terminal or go Here
If it's not working then try :
localhost:8000
{docker ip}:8000
http://0.0.0.0:8000
When the server is running to close properly,
you just need to ctrl c
and run sudo docker-compose down
You can use sudo docker-compose up
and have different behavior
at the beginning you should see something like that :
server_1 | You can change the mode by changing the value of LAUNCH_MODE in the .env file
server_1 | 'r' -> release
server_1 | 'a' -> all (fmt, clippy, test, release)
server_1 | 'd' -> debug
server_1 | 't' -> test
server_1 | 'ts' -> run a specific test
server_1 | 'c' -> clippy (upgrade code)
server_1 | 'f' -> fmt (syntax format)
server_1 | 'rd' -> recreate the database
server_1 | Link to the database: success
server_1 | Mode is: all verif 'a'
Everything has been explain you just need to go to the server/.env
file and change the value of LAUNCH_MODE
to the mode you want
'r' release
launch the test before to make sure everything should work: better performance in runtime,log level is critical
, so only important message are displayed in the terminal'd' debug
use for full data display to the terminallog level normal
't' test
launch the test of the server'ts' specific test
launch a specific test of the server'c' clippy
launch the clippy functionality of cargo (test if their better syntax solution)'f' fmt
launch the fmt functionality of cargo (reformat the code with the rust convention)'rd' diesel redo
recreate the database (erase all data) if you change the structure and also reset the value in thedata.json
'a' all
launch fmt, clippy, test, and server in release use this before a commit to make sure everything works fine
To see if the server passes all the tests you need to:
You can change the in the server/.env
file the value of LAUNCH_MODE
to t
and do sudo docker-compose up
go to the root
of the project and do:
sudo docker-compose up -d
to launch the container in daemon modesudo docker container ls
You should see something like this
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1bea5cd8857b to_do_reminder_server "bash -c 'cargo run …" 19 minutes ago Up 6 minutes 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp to_do_reminder_server_1
- copy the id under
CONTAINER ID
sudo docker container exec CONTAINERID cargo test
replaceCONTAINERID
by the id of your container- launch the test and hopefully everything will be ok
- Dont forget to do
sudo docker-compose down
once you're done
- The password is saved in the database with the encryption
PBKDF2
- token are generated by serialise and
sha256
encryption plus a private cookie withbase64
hash the token and as aexpire_date of 2 hours
and a cookie to set the expired_token of12 hours
after that the server will no longer sendexpired token
butforbidden
status
You can try every status code by going to {server}/status/<code>
401
only for admin403
not login but action needs to404
not found405
try to do something only accessible for visitors417
code should not happen, it's when the user of the token doesn't exist418
expired token500
error internal (my bad)
First the server will always have an admin account
with a default password password
(you can change it) and email value same as the smtp email
The server use 3 table each one has a very specific utility
The utility of this table is the one that link the other and also let the user create an account have his own personal data
id
primary key of the table auto incrementusername
password
perm
boolean true if an adminpicture
boolean true if the user a a picture uploademail
confirm_email
if the user has confirm is email
Contains the to-do, the principal functionality
id
primary key of the table auto incrementprogress
integer in [0; 100] show the % of the to-doid_owner
foreign key from user allow the link between the tabletitle
date
limite-date of the to-dopriority
content
extra description optional
Some nice functionality who will make the life of the user far better. with a preferred setting like the sorting of the to-do
id
the if is the primary keyid_owner
foreign key of usersort
change the behavior of the sorting of the list of to-dodisplay
behavior for the display in the home
GET
:/
Home of the websiteGET
:/status/code
With<code>
a response status code allows to simulate a code to see the template to it
GET
:/account/home
Send to login if not login else display user personal pageGET
:/account/users
Allows to see every member of the website (if you're connected as admin get state of the database)GET
:/account/register
Show a form to fill to create a new accountPOST
:/account/register
Handle the form and try to create the accountGET
:/account/users
Show a form to fill to loginPOST
:/account/login
Handle the form and try to loginPUT
:/account/logout
Disconnect the userDELETE
:/account/delete
Try to delete the userDELETE
:account/delete_admin/<id>
for admin account delete the username putGET
:/account/edit
Show form to change password or profile picturePOST
:/account/edit
Handle the change passworddelete
:/account/edit/remove_picture/<id>
allow to remove the picturePOST
:/account/set/picture
Handle the new picturePUT
:/account/send_code
send a code to confirm the emailPOST
:/account/confirm
form to enable the emailGET
:/account/code_password
form when you forget your passwordPUT
:/account/code_password
change the password and send the new value per emailPUT
:/account/new_email
change the email and send a confirm code to enable the email
GET
:/to-do/home
show the to-do in the ordre of creation with some actionGET
:/to-do/create/<callback>
display form to create a to-do the callback is useful for the go backPOST
:/to-do/create/<callback>
allow to create in the database the to-doDELETE
:/to-do/owner/<id>
delete all the to-do of the account inDELETE
:/to-do/owner/done/<id>
delete all the to-do done of the account inDELETE
:/to-do/delete/<id>
delete the to-do with theGET
:/to-do/edit/<id>
show the forum to edit a to-doPUT
:/to-do/edit/<id>
put to save the new dataPUT
:/to-do/set_progress/<id>/<value>
allow to just change the progress value
GET
:/preference/home
show the preference to the user and allow him to change themPUT
:/preference/set/display
put a new display valuePUT
:/preference/set/mode
put a new sorting mode