예제 #1
0
파일: app.py 프로젝트: AlecSKlein/GiftlyAPI
def register_user_():
    js = request.get_json(force=True)
    email = js.get('email')
    password = js.get('password')
    fname = js.get('fname')
    lname = js.get('lname')

    #Missing arguments
    if not email or not password or not fname or not lname:
        return abort(400)
    fname = formatting.stringify_sql(fname)
    lname = formatting.stringify_sql(lname)
    email = formatting.stringify_sql(email)

    if giftlydb.insert_user(
        (giftlydb.generate_uuid(), email, fname, lname,
         formatting.stringify_sql(encryption.hash_password(password)), '1')):
        values = giftlydb.select_values(values="USERID, EMAIL, FNAME, LNAME",
                                        table="User",
                                        where="EMAIL=" + email)
        value_dict = giftlydb.row_to_dict(values)
        userid = value_dict[0]['userid']
        email = value_dict[0]['email']
        lname = value_dict[0]['lname']
        fname = value_dict[0]['fname']
        return jsonify(
            formatting.format_user_json(userid=userid,
                                        email=email,
                                        lname=lname,
                                        fname=fname))
    else:
        return abort(400)
예제 #2
0
파일: app.py 프로젝트: AlecSKlein/GiftlyAPI
def test():
    values = giftlydb.select_values(values="USERID, EMAIL, FNAME, LNAME, STATE", table="User")
    if values:
        value_dict = giftlydb.row_to_dict(values)
        dicts = {}
        for dict in value_dict:
            value_dict = giftlydb.row_to_dict(values)
            userid = dict['userid']
            email = dict['email']
            lname = dict['lname']
            fname = dict['fname']
            dicts[email] = formatting.format_user_json(userid=userid, email=email, lname=lname, fname=fname)

        print "dict"
        print dicts
        return jsonify({"users":dicts})
예제 #3
0
파일: app.py 프로젝트: AlecSKlein/GiftlyAPI
def test():
    values = giftlydb.select_values(
        values="USERID, EMAIL, FNAME, LNAME, STATE", table="User")
    if values:
        value_dict = giftlydb.row_to_dict(values)
        dicts = {}
        for dict in value_dict:
            value_dict = giftlydb.row_to_dict(values)
            userid = dict['userid']
            email = dict['email']
            lname = dict['lname']
            fname = dict['fname']
            dicts[email] = formatting.format_user_json(userid=userid,
                                                       email=email,
                                                       lname=lname,
                                                       fname=fname)

        print "dict"
        print dicts
        return jsonify({"users": dicts})
예제 #4
0
파일: app.py 프로젝트: AlecSKlein/GiftlyAPI
def login_user():
    js = request.get_json(force=True)
    email = js.get('email')
    password = js.get('password')
    if giftlydb.row_exists("EMAIL",
                           'User',
                           "EMAIL=" + formatting.stringify_sql(email),
                           state='1'):
        hashed_password = giftlydb.select_values(
            "PASSWORD", "USER",
            "EMAIL=" + formatting.stringify_sql(email))[0]['PASSWORD']
    else:
        print 'abort'
        return abort(400)
    login_auth = None
    if encryption.check_hashed_password(password, hashed_password):
        login_auth = True
    else:
        login_auth = False

    values = giftlydb.select_values(
        values="USERID, EMAIL, FNAME, LNAME, STATE",
        table="User",
        where="EMAIL=" + email)
    if values:
        value_dict = giftlydb.row_to_dict(values)
        userid = value_dict[0]['userid']
        email = value_dict[0]['email']
        fname = value_dict[0]['fname']
        lname = value_dict[0]['lname']

    return jsonify(
        formatting.format_user_json(userid=userid,
                                    email=email,
                                    fname=fname,
                                    lname=lname,
                                    auth=login_auth))
예제 #5
0
파일: app.py 프로젝트: AlecSKlein/GiftlyAPI
def login_user():
    js = request.get_json(force=True)
    email = js.get('email')
    password = js.get('password')
    if giftlydb.row_exists("EMAIL", 'User', "EMAIL="+formatting.stringify_sql(email), state='1'):
        hashed_password = giftlydb.select_values("PASSWORD", "USER", "EMAIL=" + formatting.stringify_sql(email))[0]['PASSWORD']
    else:
        print 'abort'
        return abort(400)
    login_auth = None
    if encryption.check_hashed_password(password, hashed_password):
        login_auth = True
    else:
        login_auth = False

    values = giftlydb.select_values(values="USERID, EMAIL, FNAME, LNAME, STATE", table="User", where="EMAIL="+email)
    if values:
        value_dict = giftlydb.row_to_dict(values)
        userid = value_dict[0]['userid']
        email = value_dict[0]['email']
        fname = value_dict[0]['fname']
        lname = value_dict[0]['lname']

    return jsonify(formatting.format_user_json(userid=userid, email=email, fname=fname, lname=lname, auth=login_auth))
예제 #6
0
파일: app.py 프로젝트: AlecSKlein/GiftlyAPI
def register_user_():
    js = request.get_json(force=True)
    email = js.get('email')
    password = js.get('password')
    fname = js.get('fname')
    lname = js.get('lname')

    #Missing arguments
    if not email or not password or not fname or not lname:
        return abort(400)
    fname = formatting.stringify_sql(fname)
    lname = formatting.stringify_sql(lname)
    email = formatting.stringify_sql(email)

    if giftlydb.insert_user((giftlydb.generate_uuid(), email, fname, lname, formatting.stringify_sql(encryption.hash_password(password)), '1')):
        values = giftlydb.select_values(values="USERID, EMAIL, FNAME, LNAME", table="User", where="EMAIL="+email)
        value_dict = giftlydb.row_to_dict(values)
        userid = value_dict[0]['userid']
        email = value_dict[0]['email']
        lname = value_dict[0]['lname']
        fname = value_dict[0]['fname']
        return jsonify(formatting.format_user_json(userid=userid, email=email, lname=lname, fname=fname))
    else:
        return abort(400)