import RPi.GPIO as GPIO
from mfrc522 import SimpleMFRC522

GPIO.setwarnings(False)

reader = SimpleMFRC522()

#while True:
 #   try:
     #   id, text = reader.read()
      #  print(id)
      #  print(text)
  #  finally:
       # GPIO.cleanup()

def auth():
    try:
        id, text = reader.read()
        print(id)
        print(text)
        GPIO.cleanup()
    
        if (id == 526343407741):
            print("Authorized")
            GPIO.cleanup()
            return True
        else:
            print("Unauthorized")
            GPIO.cleanup()
            return False
    except:
        GPIO.cleanup()
        print("Error reading")
        return False
    
#auth()