<s> from django . db import models <EOL> from django_twofactor . util import decrypt_value , check_raw_seed , get_google_url <EOL> from base64 import b32encode <EOL> from socket import gethostname <EOL> class UserAuthToken ( models . Model ) : <EOL> user = models . OneToOneField ( "<STR_LIT>" ) <EOL> encrypted_seed = models . CharField ( max_length = <NUM_LIT> ) <EOL> created_datetime = models . DateTimeField ( <EOL> verbose_name = "<STR_LIT>" , auto_now_add = True ) <EOL> updated_datetime = models . DateTimeField ( <EOL> verbose_name = "<STR_LIT>" , auto_now = True ) <EOL> def check_auth_code ( self , auth_code ) : <EOL> """<STR_LIT>""" <EOL> return check_raw_seed ( decrypt_value ( self . encrypted_seed ) , auth_code ) <EOL> def google_url ( self , name = None ) : <EOL> """<STR_LIT>""" <EOL> if not name : <EOL> username = self . user . username <EOL> hostname = gethostname ( ) <EOL> name = "<STR_LIT>" % ( username , hostname ) <EOL> return get_google_url ( <EOL> decrypt_value ( self . encrypted_seed ) , <EOL> name <EOL> ) <EOL> def b32_secret ( self ) : <EOL> """<STR_LIT>""" <EOL> return b32encode ( decrypt_value ( self . encrypted_seed ) ) <EOL> from django_twofactor import auth_forms </s>
