U
    Md                     @   s*   d dl T d dlmZ G dd dejZdS )    )*)cmf_auth_two_factorc                   @   s   e Zd Zdd ZdS )CmfAuthTwoFactorc              	   C   s   dd l }dd l}dd l}dd l}dd l}d }| j sN| }|| _|   nt	
  | j }W 5 Q R X | dg d|j| jd jj d| d}|jdddd	}|| |jd
d |jddd}	| }
|	j|
dd ||
 d}|S )Nr   zpersons.loginzotpauth://totp/EvaTeam:z?secret=z&issuer=EvaTeam   
      )versionZbox_sizeZborderT)ZfitZblackZwhite)Z
fill_colorZ
back_colorZPNG)formatzutf-8)pyotpqrcodebase64iourllibZtopt_secretloadZrandom_base32ZsaveZcmfutilZdisable_aclZdecryptZload_fieldsparseZquoteZpersonsZloginvalueZQRCodeZadd_dataZmakeZ
make_imageBytesIOZ	b64encodegetvaluedecode)selfr
   r   r   r   r   ZsecretZurlZqrZimgbufferZbase64_image r   #./cmf/models/cmf_auth_two_factor.pytopt_qrcode   s,    


$
zCmfAuthTwoFactor.topt_qrcodeN)__name__
__module____qualname__r   r   r   r   r   r      s   r   N)Zcmf.includeZ
cmf.fieldsr   r   r   r   r   r   <module>   s   