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)
def add_friend_gift(): js = request.get_json(force=True) asin = formatting.stringify_sql(js.get('asin')) friendid = formatting.stringify_sql(js.get('friendid')) description = formatting.stringify_sql(js.get('description')) if giftlydb.insert_gift((asin, friendid, description, '1')): return jsonify({"friendid":friendid, "asin":asin, "response":200}) else: return abort(400)
def add_friend_gift(): js = request.get_json(force=True) asin = formatting.stringify_sql(js.get('asin')) friendid = formatting.stringify_sql(js.get('friendid')) description = formatting.stringify_sql(js.get('description')) if giftlydb.insert_gift((asin, friendid, description, '1')): return jsonify({"friendid": friendid, "asin": asin, "response": 200}) else: return abort(400)
def add_user_friend(): userid = request.json.get('userid') name = request.json.get('name') dob = request.json.get('dob') success = False if userid and name and dob: name = formatting.stringify_sql(name) dob = formatting.stringify_sql(dob) success = giftlydb.insert_friend((giftlydb.generate_uuid(), userid, name, dob, '1')) return jsonify(giftlydb.get_friend_dict(name))
def add_user_friend(): userid = request.json.get('userid') name = request.json.get('name') dob = request.json.get('dob') success = False if userid and name and dob: name = formatting.stringify_sql(name) dob = formatting.stringify_sql(dob) success = giftlydb.insert_friend( (giftlydb.generate_uuid(), userid, name, dob, '1')) return jsonify(giftlydb.get_friend_dict(name))
def add_friend_interest(): js = request.get_json(force=True) interestname = formatting.stringify_sql(js.get('interestname')) friendid = js.get('friendid') if giftlydb.insert_interest((interestname, friendid, '1')): return jsonify({'friendid':friendid, 'interestname':interestname,'response':200}) else: return abort(400)
def add_friend_interest(): js = request.get_json(force=True) interestname = formatting.stringify_sql(js.get('interestname')) friendid = js.get('friendid') if giftlydb.insert_interest((interestname, friendid, '1')): return jsonify({ 'friendid': friendid, 'interestname': interestname, 'response': 200 }) else: return abort(400)
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))
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))
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)
def get_user(): js = request.get_json(force=True) email = js.get('email') email = formatting.stringify_sql(email) return jsonify(giftlydb.get_user_dict(email))