예제 #1
0
def register():
    data = json.loads(request.data)
    email = data['email']
    username = data['name']
    password = data['password']

    try:
        app.logger.debug("Registration attempt ('%s', '%s')" % (username, email))

        if (db.email_exists(email)):
            app.logger.debug("Registration for '%s' failed - email already taken" % email)
            return jsonify({"success":False, "error_message":"email already registered"}), 409

        if (db.username_exists(username)):
            app.logger.debug("Registration for '%s' failed - username already taken" % username)
            return jsonify({"success":False, "error_message":"username already taken"}), 409

        if (len(password) < 8):
            app.logger.debug("Registration for '%s' failed - password too short" % username)
            return jsonify({"success":False, "error_message":"password too short"}), 422

        if (len(password) > 64):
            app.logger.debug("Registration for '%s' failed - password too long" % username)
            return jsonify({"success":False, "error_message":"password too long"}), 422

        db.add_new_user(email, username, password)
        app.logger.info("Registered new user ('%s', '%s')" % (username, email))

        return jsonify({"success":True}), 201

    except Exception as e:
        app.logger.error("Error while processing registration ('%s', '%s')\n%s" % (username, email, e))
        return jsonify({"success":False, "error_message":"internal server error"}), 500
예제 #2
0
파일: main.py 프로젝트: Bobberclobber/agora
def register_user(user_name, password, e_mail, country, city, avatar_image):
    if db.email_exists(e_mail):
        return jsonify({"response": ["E-Mail Already Registered"]})
    elif db.user_name_exists(user_name):
        return jsonify({"response": ["User Name Taken"]})
    else:
        db.add_new_user(user_name, password, e_mail, country, city, avatar_image)
        return jsonify({"response": ["Success"]})
예제 #3
0
def register_user(user_name, password, e_mail, country, city, avatar_image):
    if db.email_exists(e_mail):
        return jsonify({"response": ["E-Mail Already Registered"]})
    elif db.user_name_exists(user_name):
        return jsonify({"response": ["User Name Taken"]})
    else:
        db.add_new_user(user_name, password, e_mail, country, city, avatar_image)
        return jsonify({"response": ["Success"]})
예제 #4
0
def update_user_data(original_user_name, original_e_mail, new_user_name, new_e_mail,
                     new_password, new_country, new_city, new_location, new_image):
    response = "Success"
    if original_user_name != new_user_name and db.user_name_exists(new_user_name):
        response = "User Name Exists"
    elif original_e_mail != new_e_mail and db.email_exists(new_e_mail):
        response = "E-Mail Exists"
    else:
        db.update_user_data(original_user_name, new_user_name, new_e_mail, new_password, new_country, new_city,
                            new_location, new_image)
    return jsonify({"response": [response]})
예제 #5
0
def update_user_data(original_user_name, original_e_mail, new_user_name, new_e_mail,
                     new_password, new_country, new_city, new_location, new_image):
    response = "Success"
    if original_user_name != new_user_name and db.user_name_exists(new_user_name):
        response = "User Name Exists"
    elif original_e_mail != new_e_mail and db.email_exists(new_e_mail):
        response = "E-Mail Exists"
    else:
        db.update_user_data(original_user_name, new_user_name, new_e_mail, new_password, new_country, new_city,
                            new_location, new_image)
    return {"response": response}
예제 #6
0
def register():
    firstName = input('\nWhat is your first name? \t')
    lastName = input('What is your last name? \t')
    email = input('\nEnter your email address: \t')
    if db.email_exists(email):
        print("This email already exists in our records, try logging in")
        return False
    else:
        # newPassword = input('\nCreate a new password:\t')
        newPassword = getpass('Create a new password: \t')
        newAccount = accountGen()
        newBalance = 0.00
        newUser = [firstName, lastName, email, newPassword, str(newBalance)]
        db.create(newAccount, newUser)
        print(
            f'\nWelcome to Divus Bank, your new Account Number is {newAccount} \n'
        )
        return True
예제 #7
0
def user_exists():
    data = json.loads(request.data)
    email = data['email']
    app.logger.debug("Check if email '%s' exists" % email)
    return jsonify({"success":True, "response":db.email_exists(email)}), 200