def set_phone_verified_handler(doublename): logger.debug("/smsverified from user %s", doublename) user = db.get_user_by_double_name(conn, doublename) logger.debug(user) emitOrQueue("sms_verification", "", room=user["double_name"]) return Response("Ok")
def on_checkname(data): logger.debug("/checkname %s", data) doublename = data.get("doubleName") user = db.get_user_by_double_name(conn, doublename) if user: logger.debug("user %s", user["double_name"]) emit("nameknown") else: logger.debug("user %s was not found", doublename) emit("namenotknown")
def on_login(data): logger.debug("/login %s", data) double_name = data.get("doubleName") data["type"] = "login" milli_sec = int(round(time.time() * 1000)) data["created"] = milli_sec user = db.get_user_by_double_name(conn, double_name) if user: logger.debug("[login]: User found %s", user["double_name"]) emitOrQueue("login", data, room=user["double_name"])
def get_user_handler(doublename): logger.debug("/doublename user %s", doublename) user = db.get_user_by_double_name(conn, doublename) if user is not None: logger.debug("DB /api/users/: %s", user) data = { "doublename": user["double_name"], "publicKey": user["public_key"] } response = app.response_class(response=json.dumps(data), mimetype="application/json") logger.debug("User found") return response else: logger.debug("User not found") return Response("User not found", status=404)
def mobile_registration_handler(): logger.debug("/mobile_registration_handler ") body = request.get_json() double_name = body.get("doubleName").lower() email = body.get("email").lower().strip() public_key = body.get("public_key") if double_name == None or email == None or public_key == None: return Response("Missing data", status=400) else: if len(double_name) > 55 and double_name.endswith(".3bot"): return Response( "doubleName exceeds length of 50 or does not contain .3bot", status=400) user = db.get_user_by_double_name(conn, double_name) if user is None: update_sql = "INSERT into users (double_name, sid, email, public_key, device_id) VALUES(?,?,?,?,?);" db.insert_user(conn, update_sql, double_name, "", email, public_key, "") return Response("Succes", status=200)
def verify_signed_data(double_name, data): user = db.get_user_by_double_name(conn, double_name) return verify_signed_data_with_public_key(user["public_key"], data)
def cancel_login_attempt(doublename): logger.debug("/cancel %s", doublename) user = db.get_user_by_double_name(conn, doublename) sio.emit("cancelLogin", {"scanned": True}, room=user["double_name"]) return Response("Canceled by User")