Example #1
0
def create_user():
    code = request.args.get('code')
    lat = request.args.get('lat')
    lon = request.args.get('lon')

    new_user = User(lat, lon, code)
    new_user.add_user()
    return create_response(data={'user_id': int(new_user.id)}, status=201)
Example #2
0
def create_user():
    data = request.get_json()
    if 'username' not in data or 'email' not in data or 'password' not in data:
        return bad_request('Must include username, email and password fields.')
    if User.query.filter_by(username=data['username']).first():
        return bad_request('Username has already been taken.')
    if User.query.filter_by(email=data['email']).first():
        return bad_request('Email has been previously registered.')
    if User.check_email(data['email']) is not None:
        User.add_user(username = data['username'], email = data['email'], password = data['password'])
        response = make_response(jsonify(message = "User registered!"), 201)
        return response
    else:
        return bad_request('Invalid email!')
Example #3
0
 def post(self):
     data = request.get_json()
     user = User.get_user(data["username"])
     if user == None:
         if not validateEmail(data["email"]):
             return make_response(jsonify({'email': 'Email inválido!'}),
                                  400)
         else:
             result = User.add_user(data)
             if result:
                 return make_response(jsonify({'redirect': '/login'}), 200)
             return make_response(
                 jsonify({
                     'error':
                     'Ocorreu um erro no registo. Tente outra vez.'
                 }), 500)
     return make_response(jsonify({'username': '******'}),
                          400)
Example #4
0
def handle_register():
    request_body_user = request.data

    decoded_object = json.loads(request_body_user)
    return jsonify(User.add_user(decoded_object)), 200