refactor(chalice): changed forget password
This commit is contained in:
parent
524394393c
commit
7878f10a8b
1 changed files with 6 additions and 3 deletions
|
|
@ -1,12 +1,15 @@
|
|||
import logging
|
||||
|
||||
import schemas
|
||||
from chalicelib.core import users
|
||||
from chalicelib.utils import email_helper, captcha, helper, smtp
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def reset(data: schemas.ForgetPasswordPayloadSchema):
|
||||
print(f"====================== reset password {data.email}")
|
||||
logger.info(f"forget password request for: {data.email}")
|
||||
if helper.allow_captcha() and not captcha.is_valid(data.g_recaptcha_response):
|
||||
print("error: Invalid captcha.")
|
||||
return {"errors": ["Invalid captcha."]}
|
||||
if not smtp.has_smtp():
|
||||
return {"errors": ["no SMTP configuration found, you can ask your admin to reset your password"]}
|
||||
|
|
@ -15,5 +18,5 @@ def reset(data: schemas.ForgetPasswordPayloadSchema):
|
|||
invitation_link = users.generate_new_invitation(user_id=a_users["userId"])
|
||||
email_helper.send_forgot_password(recipient=data.email, invitation_link=invitation_link)
|
||||
else:
|
||||
print(f"!!!invalid email address [{data.email}]")
|
||||
logger.warning(f"!!!invalid email address [{data.email}]")
|
||||
return {"data": {"state": "A reset link will be sent if this email exists in our system."}}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue