コード例 #1
0
    def post(self):
        """Creates a new user."""
        post_data = request.get_json()
        username = post_data.get("username")
        email = post_data.get("email")
        response_object = {}

        user = get_user_by_email(email)
        if user:
            response_object["message"] = "Sorry. That email already exists."
            return response_object, 400

        add_user(username, email)
        response_object["message"] = f"{email} was added!"
        return response_object, 201
コード例 #2
0
def post_user():
    print(request)
    post_data = request.get_json()
    print(post_data)
    username = post_data['username']
    email = post_data['email']
    password = post_data['password']
    response_object = {}

    user = get_user_by_email(email)
    if user:
        response_object["message"] = "Sorry. That email already exists."
        return response_object, 400
    add_user(username, email, password)
    response_object["message"] = f"{email} was added!"
    return response_object, 201
コード例 #3
0
    def post(self):
        """Creates a new user."""
        post_data = request.get_json()
        username = post_data.get("username")
        email = post_data.get("email")
        password = post_data.get("password")
        role = post_data.get("role")
        sponsor_logo = post_data.get("sponsor_logo")
        sponsor_headline = post_data.get("sponsor_headline")
        sponsor_slug = post_data.get("sponsor_slug")
        response_object = {}

        user = get_user_by_email(email)
        if user:
            response_object["message"] = "Sorry. That email already exists."
            return response_object, 400
        new_user = add_user(username, email, password, role)
        response_object["user_id"] = new_user.id
        response_object[
            "message"] = message = f"A new user with email {email} was added!"

        try:
            # print(f"Sending email to {email}")
            msg = "New user account created in GoodDriver App for email: " + email
            send_email("*****@*****.**", "New user created.", msg)
            # Req Change 3:
            send_email(email, "New user account created in GoodDriver App",
                       "Welcome to the GoodDriver App!")
        except:
            pass

        return response_object, 201
コード例 #4
0
    def post(self):
        post_data = request.get_json()
        username = post_data.get("username")
        email = post_data.get("email")
        password = post_data.get("password")

        user = get_user_by_email(email)
        if user:
            auth_namespace.abort(400, "Sorry. That email already exists.")
        user = add_user(username, email, password)
        return user, 201
コード例 #5
0
    def post(self):
        """Creates a new user."""

        payload = request.get_json()
        username = payload.get("username")
        email = payload.get("email")
        password = payload.get("password")

        user = get_user_by_email(email)
        if not user:
            add_user(username, email, password)
            return {
                "message": f"user {email} was created",
                "status": "success"
            }, 201
        else:
            return {
                "message": f"user {email} already exists",
                "status": "failed"
            }, 400
コード例 #6
0
ファイル: views.py プロジェクト: libdx/flask-microservices
    def post(self):
        """Register and returns new user."""
        payload = request.get_json()
        username = payload.get("username")
        email = payload.get("email")
        password = payload.get("password")

        user = get_user_by_email(email)
        if user:
            namespace.abort(400, f"User with email {email} already exists")
        user = add_user(username, email, password)

        return user, 201