This commit is contained in:
EggMan20339 2024-05-09 22:34:53 -04:00
parent b42085c6ef
commit eabd40db41

10
main.py
View File

@ -33,7 +33,7 @@ On Windows, the native WebAuthn API will be used.
""" """
import time import time
import configparser import configparser
gpie = True gpie = False
if gpie: if gpie:
import RPi.GPIO as GPIO import RPi.GPIO as GPIO
import pickle import pickle
@ -54,7 +54,7 @@ config = configparser.ConfigParser()
config.read('config.ini') config.read('config.ini')
nfc = False isNfc = False
dbusername = config.get('Setup', 'dbusername') dbusername = config.get('Setup', 'dbusername')
dbpassword = config.get('Setup', 'dbpassword') dbpassword = config.get('Setup', 'dbpassword')
@ -110,10 +110,10 @@ class CliInteraction(UserInteraction):
print("User Verification required.") print("User Verification required.")
return True return True
clf = nfc.ContactlessFrontend('usb')
def read_nfc_tag(): def read_nfc_tag():
clf = None clf = None
try: try:
clf = nfc.ContactlessFrontend('usb')
tag = clf.connect(rdwr={'on-connect': lambda tag: False}) tag = clf.connect(rdwr={'on-connect': lambda tag: False})
nfc = True nfc = True
return tag.identifier if tag else None return tag.identifier if tag else None
@ -126,7 +126,7 @@ def read_nfc_tag():
pass pass
while True: while True:
nfc = False isNfc = False
if gpie: if gpie:
GPIO.output(door, GPIO.LOW) GPIO.output(door, GPIO.LOW)
@ -247,7 +247,7 @@ while True:
request_options, state = server.authenticate_begin(credentials, user_verification=uv) request_options, state = server.authenticate_begin(credentials, user_verification=uv)
# Authenticate the credential # Authenticate the credential
if not nfc: if not isNfc:
result = client.get_assertion(request_options["publicKey"]) result = client.get_assertion(request_options["publicKey"])
else: else:
sendme = cbor.encode(credentials) sendme = cbor.encode(credentials)