Skip to content

Commit 12d945a

Browse files
authored
Merge pull request #470 from Seluj78/env-files
2 parents 86070b2 + 1291f9a commit 12d945a

File tree

7 files changed

+60
-3
lines changed

7 files changed

+60
-3
lines changed

.env.template

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# To copy as .env.docker to use as docker-compose
2+
# Or .env for development for the backend
3+
4+
FLASK_PORT=5000 # Flask port
5+
FLASK_DEBUG=true
6+
FLASK_HOST=0.0.0.0 # Flask host
7+
FLASK_SECRET_KEY=A_SECRET_KEY # Flask secret key
8+
9+
CELERY_BROKER_URL=redis://redis:6379/0 # Celery broker uri. Leave as is for docker
10+
CELERY_RESULT_BACKEND=redis://redis:6379/0 # celery results backend uri. Leave as is for docker
11+
12+
DB_HOST=mysql # Database host. Leave as is for docker
13+
DB_PORT=3306 # Database port. Leave as is for docker
14+
DB_USER=matcha # Database user. Leave as is for docker
15+
DB_PASSWORD=matcha # Database password. Leave as is for docker
16+
DB_NAME=pymatcha # Database name. Leave as is for docker
17+
18+
REDIS_HOST=redis # The host of redis. Leave as is for docker
19+
REDIS_PORT=6379 # The port of redis. Leave as is for docker
20+
21+
MAIL_PASSWORD=XXX # The password of the email account pymatcha@gmail.com
22+
23+
DEBUG_AUTH_TOKEN=XXX # The auth token for debug routes
24+
25+
FRONTEND_BASE_URL=localhost:4242 # The url of the frontend, used in email for links. Leave as is for docker
26+
27+
IMGUR_CLIENT_ID=XXX # IMGUR client id, needed to populate database if not using the dump
28+
IMGUR_CLIENT_SECRET=XXX # IMGUR client secret, needed to populate database if not using the dump

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,16 @@ Matcha is a [42](https://42.fr) school project aiming to teach how to make a dat
2222
You can find the subject [here](https://github.com/Seluj78/PyMatcha/blob/dev/subject.pdf)
2323

2424
### Installation
25+
26+
First of all, contact [Jules](https://github.com/seluj78) or [Lauris](https://github.com/supalarry) to get the env files.
27+
28+
For more information, checkout [the backend .env.template](https://github.com/Seluj78/PyMatcha/blob/dev/.env.template) and [the frontend .env.template](https://github.com/Seluj78/PyMatcha/blob/dev/frontend/.env.template)
29+
2530
#### For production
2631
You can simply download or git clone the project and, once inside of it, run `docker-compose up --build`.
32+
2733
The website will be accessible on port `4242`.
34+
2835
#### For developpment
2936
First of all, clone or download the repository, extract it if necessary then cd into it.
3037

backend/PyMatcha/routes/api/auth/login.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
from PyMatcha.utils.decorators import validate_params
3434
from PyMatcha.utils.errors import NotFoundError
3535
from PyMatcha.utils.errors import UnauthorizedError
36+
from PyMatcha.utils.mail import send_mail_text
3637
from PyMatcha.utils.password import check_password
3738
from PyMatcha.utils.success import Success
3839
from PyMatcha.utils.success import SuccessOutput
@@ -73,6 +74,12 @@ def auth_login():
7374
u.is_online = True
7475
u.dt_lastseen = datetime.datetime.utcnow()
7576
u.save()
77+
send_mail_text.delay(
78+
dest=u.email,
79+
subject="[Matcha] Login notification",
80+
body=f"Someone logged in into your account at {datetime.datetime.utcnow()}."
81+
f"If you believe it wasn't you, please change your password immediately!",
82+
)
7683
ret = {"access_token": access_token, "refresh_token": refresh_token, "is_profile_completed": u.is_profile_completed}
7784
return SuccessOutput("return", ret)
7885

backend/PyMatcha/routes/api/auth/password.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
You should have received a copy of the GNU General Public License
1717
along with this program. If not, see <https://www.gnu.org/licenses/>.
1818
"""
19+
import datetime
1920
import logging
2021

2122
from flask import Blueprint
@@ -31,6 +32,7 @@
3132
from PyMatcha.utils.errors import BadRequestError
3233
from PyMatcha.utils.errors import NotFoundError
3334
from PyMatcha.utils.mail import send_mail_html
35+
from PyMatcha.utils.mail import send_mail_text
3436
from PyMatcha.utils.static import FRONTEND_PASSWORD_RESET_URL
3537
from PyMatcha.utils.success import Success
3638

@@ -87,6 +89,12 @@ def reset_password():
8789
u.password = hash_password(data["password"])
8890
u.previous_reset_token = token
8991
u.save()
92+
send_mail_text.delay(
93+
dest=u.email,
94+
subject="[Matcha] Password change notification",
95+
body=f"Your password was changed at {datetime.datetime.utcnow()}."
96+
f"If you believe it wasn't you, please change it immediately!",
97+
)
9098
logging.debug("Password reset successfully")
9199
return Success("Password reset successful.")
92100

backend/PyMatcha/routes/api/profile/edit.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,9 @@ def edit_password():
212212
current_user.save()
213213
send_mail_text.delay(
214214
dest=current_user.email,
215-
subject="Password change notification",
215+
subject="[Matcha] Password change notification",
216216
body=f"Your password was changed at {datetime.datetime.utcnow()}."
217-
f"If you believe it wasn't you, please change it immediatly!",
217+
f"If you believe it wasn't you, please change it immediately!",
218218
)
219219
logging.info(f"Edited email for {current_user.id}")
220220
return Success("User password successfully updated.")

backend/PyMatcha/routes/api/search.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def search():
7474
continue
7575

7676
distance = _get_distance(current_user.geohash, user.geohash)
77-
if distance:
77+
if distance is not None:
7878
if distance > max_distance:
7979
if max_distance != -1:
8080
continue

frontend/.env.template

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# To copy as .env
2+
3+
VUE_APP_BACKEND_BASE_URL=http://localhost:8080 # The url of the backend. Leave as is for docker
4+
VUE_APP_ACCESS_TOKEN=matchaAccessToken # The tokens, default values
5+
VUE_APP_REFRESH_TOKEN=matchaRefreshToken # The tokens, default values
6+
VUE_APP_VUEX_PERSISTED_STATE=vuex # The name of the persisted state cookie
7+
VUE_APP_SECURE_LS_METADATA=_secure__ls__metadata

0 commit comments

Comments
 (0)