def self_sign_up(user_id=None): """ :param user_id: 'sub' field from Google id_token supplied in header Authenticate: Bearer <id_token> :return: OK """ user = get_user_from_id_token(request.headers['Authorization'].split(" ")[1]) returned_code = UserDAO.set(user) if returned_code == 0: data = { "code": 200, "fields": "", "message": "OK" } js = json.dumps(data) resp = Response(js, status=200, mimetype='application/json') resp.headers['Content-Type'] = 'application/json; charset=utf-8' else: data = { "code": 400, "fields": "string", "message": "Malformed Data" } js = json.dumps(data) resp = Response(js, status=400, mimetype='application/json') resp.headers['Content-Type'] = 'application/json; charset=utf-8' return resp
def create_user(user_id=None): """ Create new user from json object :param user_id: :return: """ if request.headers['Content-Type'] == 'application/json': dict_data = { 'userID': 0, 'firstName': "", 'lastName': "", 'email': "", 'phone': "", 'userStatus': 0 } dict_data1 = request.json dict_data.update(dict_data1) user = User(dict_data) else: data = { "code": 400, "fields": "Content-Type", "message": "Malformed Data" } js = json.dumps(data) resp = Response(js, status=400, mimetype='application/json') resp.headers['Content-Type'] = 'application/json; charset=utf-8' return resp returned_code = UserDAO.set(user) if returned_code == 0: data = { "code": 200, "fields": "", "message": "OK" } js = json.dumps(data) resp = Response(js, status=200, mimetype='application/json') resp.headers['Content-Type'] = 'application/json; charset=utf-8' else: data = { "code": 400, "fields": "returned_code", "message": "Malformed Data" } js = json.dumps(data) resp = Response(js, status=400, mimetype='application/json') resp.headers['Content-Type'] = 'application/json; charset=utf-8' return resp