def post(self): email = self.get_argument("email") """ reg = conn_remote.get("SELECT * FROM event_reg WHERE email = %s", email) if not reg: self.finish("You email is not registered.") return """ regs = conn_remote.query("SELECT * FROM event_reg_mac WHERE email = %s", email) if len(regs) >= 2: self.finish("Sorry, your email has been used for too many times") return # find mac by ip? remote_ip = self.request.remote_ip if self.request.remote_ip != '127.0.0.1' else self.request.headers['X-Forwarded-For'] device_logs = conn.query("SELECT * FROM device_log WHERE ipv4 = %s ORDER BY id DESC", remote_ip) if len(device_logs) == 0: self.finish("Something wrong!") return mac = device_logs[0]["mac"] conn_remote.execute("INSERT INTO event_reg_mac (email, mac) VALUES(%s, %s)", email, mac) # create an unquie token in database self.redirect("http://10.0.0.1:2060/wifidog/auth?token=%s" % mac)
def get(self): # find the mac address, user ip by token #/wifi/auth/?stage=login&ip=10.0.0.18&mac=84:38:35:52:ea:08&token=1234&incoming=0&outgoing=0&gw_id=0810781EE54D mac = self.get_argument("mac") reg = conn_remote.query("SELECT * FROM event_reg_mac WHERE mac = %s", mac) if reg: self.finish("Auth: 1") #success return self.finish("Auth: 0")
def get(self): slides = conn_remote.query("SELECT * FROM event_slide") self.finish({"list": [i.title for i in slides]})