
    di                     t    S SK r S SKrS SKJrJr  S SKJr  S SKJr  S SK	J
r
  SSKJr  S SKJr  SS	 jrSS
 jrg)    N)	send_mailEmailMessagesettings)timezone)	timedelta   )AppSettings)	log_errorc                    ^ [         R                  [         R                  -   S-   mSR                  U4S j[	        U 5       5       5      nU$ )z+Generate a secure random temporary passwordz!@#$%^&* c              3   P   >#    U  H  n[         R                  " T5      v   M     g 7fN)secretschoice).0ialphabets     +D:\TimeStamps\configurations\email_utils.py	<genexpr>)generate_temp_password.<locals>.<genexpr>   s     GAw~~h//s   #&)stringascii_lettersdigitsjoinrange)lengthpasswordr   s     @r   generate_temp_passwordr      s9    ##fmm3j@HwwGvGGHO    c                     SSK Jn  [        R                  " 5       nUR                  (       d  [        S[        S5      5        gUR                  Ul        UR                  Ul
        UR                  Ul        UR                  Ul        UR                  Ul        UR"                  Ul        UR&                  =(       d    UR                  Ul        U(       d  [+        USS5      nUR,                  n[.        R0                  " 5       [3        US9-   nS	UR4                  =(       d    S
 S3nSU SU SU SU SUR7                  S5       SUR4                  =(       d    S
 S3n	UR4                  =(       d    S
 SUR&                  =(       d    UR                   S3n
[9        UU	U
U /SS9  g! [         a  n[        SU5         SnAgSnAff = f)z
Send welcome email with temporary password to new employee

Args:
    user_email: Employee's email address
    user_name: Employee's full name
    temp_password: Temporary password to send
    login_url: URL for login page (optional)
r   r   send_welcome_emailzSMTP is not enabledF	LOGIN_URLzhttp://localhost:3000/login)hourszWelcome to TimeTrackerz - Your Account CredentialszHello zn,

Your account has been created. Please use the following temporary password to log in:

Temporary Password: z

Login URL: z|

IMPORTANT: You must change this password on your first login for security reasons.
This temporary password will expire in z hours (z%Y-%m-%d %H:%Mzd).

If you did not expect this email, please contact your administrator immediately.

Best regards,
z Teamz <>)subjectmessage
from_emailrecipient_listfail_silentlyTN)django.confr   r
   get_settingssmtp_enabledr   	Exception	smtp_host
EMAIL_HOST	smtp_port
EMAIL_PORTsmtp_use_tlsEMAIL_USE_TLSsmtp_use_sslEMAIL_USE_SSLsmtp_usernameEMAIL_HOST_USERsmtp_passwordEMAIL_HOST_PASSWORDsmtp_from_emailDEFAULT_FROM_EMAILgetattrtemp_password_expires_hoursr   nowr   smtp_from_namestrftimer   )
user_email	user_nametemp_password	login_urldjango_settingsapp_settingsexpires_hoursexpiration_timer'   r(   r)   es               r   r"   r"      s   >;"//1 ((*I6K,LM &2%;%;"%1%;%;"(4(A(A%(4(A(A%*6*D*D'.:.H.H+-9-I-I-g\MgMg* >[\I %@@",,.9=+II   ; ; L}MMhi YK ( #O $; ( )6h?W?WXh?i>j k
 - .e7" %33D}ERHdHd  ICht  iC  iC  HD  DE  F
!&<	
  &*s   AF$ EF$ $
G.F??G)   r   )r   r   django.core.mailr   r   r,   r   django.utilsr   datetimer   modelsr
   ErrorLogs.utilsr   r   r"    r    r   <module>rS      s(      4   !   %Hr    