def check_authenticated_ip(ip, uuid=None, username=None): time_check = datetime.datetime.utcnow() - datetime.timedelta(minutes=15) opt = dict() opt.update(dict(uuid=uuid) if uuid is not None else dict()) opt.update(dict(username__iexact=username) if username is not None else dict()) return ConfirmedUsername.objects(ip=str(ip), created__gt=time_check, **opt).order_by('-created').first()
def dev_verify_ip_username(ip, username, uuid): """ Verifies a ip with a username. Useful for registering users in a dev environment without the need for a Minecraft client/auth server. """ from models.user_model import ConfirmedUsername ConfirmedUsername(username=username, ip=ip, uuid=uuid).save() print("Success! You can now register the user %s, %s from %s" % (username, uuid, ip))
def check_authenticated_ip(ip, uuid=None, username=None): time_check = datetime.datetime.utcnow() - datetime.timedelta(minutes=15) opt = dict() opt.update(dict(uuid=uuid) if uuid is not None else dict()) opt.update( dict(username__iexact=username) if username is not None else dict()) return ConfirmedUsername.objects(ip=str(ip), created__gt=time_check, **opt).order_by('-created').first()
def add_authenticated_ip(username, uuid, ip): confirmed = ConfirmedUsername(ip=ip, username=username, uuid=uuid) confirmed.save()