Example #1
0
def login():
    if("txtisessionkey" in request.cookies.keys()):
        helper = dbhelper.db_session()
        userid = loginsys.is_key_valid(helper.mongoclient, request.cookies["txtisessionkey"])
        if userid:
            return redirect("/dashboard")
    return serve_static("login.html")
Example #2
0
def index():
    name = "login/register"
    if("txtisessionkey" in request.cookies.keys()):
        helper = dbhelper.db_session()
        userid = loginsys.is_key_valid(helper.mongoclient, request.cookies["txtisessionkey"])
        user = helper.user_from_uid(userid)
        helper.close()
        name = user["username"]
    return render_template("index.html", topright_text=name)
Example #3
0
def dashboard():
    #chck cookie exists
    if not 'txtisessionkey' in request.cookies.keys():
        return app.make_response(redirect("/login")) 
    else:
        helper = dbhelper.db_session()
        userid = loginsys.is_key_valid(helper.mongoclient, request.cookies["txtisessionkey"])
        user = helper.user_from_uid(userid)
        helper.close()

        print request.cookies["txtisessionkey"]
        if user:
            return serve_dashboard(user)
        else:
            response = app.make_response(redirect("/login?msg=login+expired"))
            response.set_cookie("txtisessionkey", value="", expires=0)
            return response
Example #4
0
def addapi():
    if("txtisessionkey" in request.cookies.keys()):
        helper = dbhelper.db_session()
        userid = loginsys.is_key_valid(helper.mongoclient, request.cookies["txtisessionkey"])
        if "api-id" in request.form.keys():
            proper_apis = filter(lambda x: x["api-id"] == request.form["api-id"], all_apis)
            if len(proper_apis)>0:
                proper_api = proper_apis[0]
                print construct_to_fit(proper_api, request.form)
                helper.register_api_login(userid, proper_api["api-id"], construct_to_fit(proper_api, request.form))
                helper.close();
                return "successfully registered!"
            print "shit"
            return "error finding app-id"
        print "shit!"
        return "api-id DNE tho."
    else:
        return "not logged in!"
Example #5
0
def register_push():
    msg=""
    if request.method == 'POST':
        if all([ (x in request.form.keys()) for x in ["username","password","email","phone"] ] ):
            hashword = hash512(request.form["password"])
            session = dbhelper.db_session()
            try:
                session.register_user(
                    request.form["username"],
                    hashword,
                    [request.form["phone"]] ,
                    request.form["email"])
                session.close()
                return dologin(request.form)
            except(Exception) as e:
                msg = e.message
                session.close()
        else:
            msg="not all fields filled"
    response = app.make_response(redirect("/login?failure=register?msg=%s"%( quote_plus(msg)  )) )
    return response