def signUp(): response = createUser( request.json['username'], request.json['email'], request.json['password'], ) return response
def register(): if request.method == "POST": if request.form["password"] == request.form["password2"]: if auth.createUser(str(request.form["username"]),str(request.form["password"])): return redirect(url_for("login")) else: return render_template("register.html",type=1) else: return render_template("register.html")
def register(): nav = utils2.nav([["/","Home"],["Register"]]) if request.method == "POST": if request.form["password"] == request.form["password2"]: if auth.createUser(str(request.form["username"]),str(request.form["password"])): return redirect("/login?type=2") else: return render_template("register.html",type=1,nav=nav) else: return render_template("register.html",type=2,nav=nav) else: return render_template("register.html",nav=nav)
def newUser(): name = request.form.get('name') phone = request.form.get('phone') serial_no = request.form.get('serial_no') department = request.form.get('department') imei = request.form.get('imei') process = auth.createUser(name, phone, serial_no, department, imei) if process == False: response = jsonify(message=False, code=200, data="User already registered") response.status_code = 200 else: response = jsonify(message=True, code=200, data=process) response.status_code = 200 return response
c.execute(""" CREATE TABLE IF NOT EXISTS keys (id INTEGER PRIMARY KEY ASC, uname TEXT, key TEXT) """) c.execute(""" SELECT * FROM keys WHERE uname=? """, (qwargs["uname"], )) keyrow = c.fetchone() if keyrow is not None: key = base64.b64decode(keyrow[2]) info = json.loads(auth.decrypt(key, qwargs["info"])) if info is not None: #Create the user and tell the client whether or not this was successfull print auth.encrypt( key, json.dumps({ "success": auth.createUser(conn, info["uname"], info["verifier"], info["salt"]) })) conn.commit() conn.close() else: print auth.encrypt(key, json.dumps({"error": "DATA CORRUPTION"})) else: print json.dumps({"error": "NO ESTABLISHED SESSKEY"})
def signUp(): return createUser(request.args['username'], request.args['email'], request.args['password'])
def do_GET(self): conn = auth.initDB("test.db") parsed_url = urlparse.urlparse(self.path) path = parsed_url.path.split("/") qwargs = urlparse.parse_qs(parsed_url.query) #Enforce one value per query string arg for key in qwargs: qwargs[key] = qwargs[key][0] if (len(path) == 0 or path[1] == "index.html"): self.send_response(200) self.send_header("Content-Type", "text/html") self.end_headers() index_file = open("test.html", "r") self.wfile.write(index_file.read()) index_file.close() elif (path[1] == "jslib"): self.send_response(200) self.send_header("Content-Type", "text/html") self.end_headers() js_file = open("/".join(path), "r") self.wfile.write(js_file.read()) js_file.close() elif (path[1] == "register"): self.send_response(200) self.send_header("Content-Type", "application/json") self.end_headers() self.wfile.write(json.dumps({ "success": auth.createUser(conn, qwargs["uname"], qwargs["verifier"], qwargs["salt"]) })) elif (path[1] == "authenticate"): self.send_response(200) self.send_header("Content-Type", "application/json") self.end_headers() kdict = auth.generateKey(conn, qwargs["uname"], int(qwargs["A"], 16)) session_keys[qwargs["uname"]] = kdict["K"] key_verifiers[qwargs["uname"]] = kdict["M"] print "Generated sesssion key %s." % auth.hexify(kdict["K"]) self.wfile.write(json.dumps({ "s": kdict["s"], "B": kdict["B"] })) elif (path[1] == "echo"): self.send_response(200) self.send_header("Content-Type", "application/json") self.end_headers() self.wfile.write(json.dumps({ "cleartext":auth.decrypt(session_keys[qwargs["uname"]], qwargs["message"]) })) else: self.send_response(404) self.send_header("Content-Type", "text/plain") self.end_headers() self.wfile.write("What are you talking about")
c.execute(""" CREATE TABLE IF NOT EXISTS keys (id INTEGER PRIMARY KEY ASC, uname TEXT, key TEXT) """) c.execute(""" SELECT * FROM keys WHERE uname=? """, (qwargs["uname"],)) keyrow = c.fetchone() if keyrow is not None: key = base64.b64decode(keyrow[2]) info = json.loads(auth.decrypt(key, qwargs["info"])) if info is not None: #Create the user and tell the client whether or not this was successfull print auth.encrypt(key, json.dumps({ "success": auth.createUser(conn, info["uname"], info["verifier"], info["salt"]) })) conn.commit() conn.close() else: print auth.encrypt(key, json.dumps({ "error": "DATA CORRUPTION" })) else: print json.dumps({ "error": "NO ESTABLISHED SESSKEY" })