File tree Expand file tree Collapse file tree 3 files changed +17
-2
lines changed
backend/PyMatcha/routes/api Expand file tree Collapse file tree 3 files changed +17
-2
lines changed Original file line number Diff line number Diff line change 3333from PyMatcha .utils .decorators import validate_params
3434from PyMatcha .utils .errors import NotFoundError
3535from PyMatcha .utils .errors import UnauthorizedError
36+ from PyMatcha .utils .mail import send_mail_text
3637from PyMatcha .utils .password import check_password
3738from PyMatcha .utils .success import Success
3839from 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
Original file line number Diff line number Diff line change 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
1920import logging
2021
2122from flask import Blueprint
3132from PyMatcha .utils .errors import BadRequestError
3233from PyMatcha .utils .errors import NotFoundError
3334from PyMatcha .utils .mail import send_mail_html
35+ from PyMatcha .utils .mail import send_mail_text
3436from PyMatcha .utils .static import FRONTEND_PASSWORD_RESET_URL
3537from 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
Original file line number Diff line number Diff 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." )
You can’t perform that action at this time.
0 commit comments