
    Cjh_                     l    d dl Z d dlmZmZ d dlmZ d dlmZ d dlmZ dZ	dZ
ded	efd
Zdeded	efdZy)    N)datetime	timedelta)select)SessionLocal)tbl_useryour_secret_keyHS256usernamereturnc                     | t        j                         t        d      z   d}t        j                  |t
        t              S )N   )hours)subexp)	algorithm)r   utcnowr   jwtencode
SECRET_KEY	ALGORITHM)r
   payloads     ;C:\Python312\panapi\aramax_api\app\services\auth_service.pycreate_jwt_tokenr   
   s5     91#55G ::gzY??    passwordc                    t        d       t        d|         t        d|        t               }	 t        d       t        t        j                  j
                  t        j                  j                        j                  t        j                  j
                  | k(        }|j                  |      j                         }|(t        d       	 |j                          t        d       y|\  }}t        d|        t        d	|        t        d
|        ||k(  r(t        d       	 |j                          t        d       yt        d       	 |j                          t        d       y# t        $ r:}t        dt        |             Y d }~|j                          t        d       yd }~ww xY w# |j                          t        d       w xY w)Nu   🔧 verify_user() calledu   👤 Username received: u   🔓 Password received: u"   🔎 Querying database for user...u   ❌ User not found in database!u   🔁 Database session closed.Fu   ✅ User found in DB: u   📦 Password in DB: u   🔑 Password from input: u2   ✅ Plain text password matched. Login successful.Tu!   ❌ Plain text password mismatch!u   ❗ Exception during DB check:)printr   r   r   cr
   password_hashwhereexecutefetchoneclose	Exceptionstr)r
   r   dbstmtresultdb_usernamedb_passwordes           r   verify_userr,      s   	
%&	$XJ
/0	$XJ
/0	B/23hjj))8::+C+CDJJ8::K^K^bjKjkD!**,>34" 	
-.! $* [&{m45%k]34*8*56("FG 	
-. 56
 	
-.  .A7

-. 	
-.s6   BE1 -?E1 	E1 1	F4:F/F7 /F44F7 7G)r   r   r   
sqlalchemyr   app.database.connectionr   app.models.userr   r   r   r%   r   boolr,    r   r   <module>r2      sN    
 (  0 $
	@s @s @/# / / /r   