def sign_up(): if request.method == 'POST' : username=request.form['username'] password=request.form['password'] firstName=request.form['firstName'] lastName=request.form['lastName'] gender=request.form['gender'] city=request.form['city'] country=request.form['country'] infos = [username,password,firstName,lastName,gender,city,country] #mauybe check format of username for i in infos : if i is None : answer = {"success" : "False", "message" : "All fields should contain data" , "data": "" } return json.dumps(answer), 200 if len(password) < 10 : answer = {"success" : "False", "message" : "Password too short" , "data": "" } return json.dumps(answer), 200 database_helper.save_user(infos) answer = {"success" : "True", "message" : "Sucessfully signed up !" , "data": "" } return json.dumps(answer), 200 else: abort(404)
def sign_up(): input_data = request.get_json() input_email = input_data['email'] # print(input_email) if database_helper.get_user_by_email(input_email) is None: password = input_data['password'] if len(password) < 4: json.dumps({"success": False, "message": "Password too short."}) firstname = input_data['firstname'] familyname = input_data['familyname'] gender = input_data['gender'] city = input_data['city'] country = input_data['country'] response = database_helper.save_user(input_email, password, firstname, familyname, gender, city, country) if response: return json.dumps({ "success": True, "message": "Successfully created a new user." }) else: return json.dumps({ "success": False, "message": "Form data missing or incorrect type." }) else: return json.dumps({ "success": False, "message": "User already exists." }) return False
def register(): clear_terminal() print('=' * 46 + '\n' + '-' * 18 + ' Register ' + '-' * 18) username = input('\nEnter a username: '******'\n> This username is already taken. Please choose another name\n\n' + '=' * 46) answer = input('Continue? (j/n) or you can quit with exit\n: ').lower() while answer != 'exit': if answer == 'j': login() elif answer == 'n': menu() else: answer = input(': ') quit() plaintext = getpass('Enter a password: '******'\n> New user registered\n\n' + '=' * 46) answer = input('Do you want to login? (j/n) or you can quit with exit\n: ').lower() while answer != 'exit': if answer == 'j': login() elif answer == 'n': menu() else: answer = input(': ') quit()
def sign_up(): data = request.get_json() if 'email' in data and 'password' in data and 'firstname' in data and 'familyname' in data and 'gender' in data and 'city' in data and 'country' in data: if len(data['password']) > 7: result = database_helper.save_user(data['email'], data['password'], data['firstname'], data['familyname'], data['gender'], data['city'], data['country']) if result == True: return jsonify({ "success": True, "msg": "User succesfully created" }) else: return jsonify({"success": False, "msg": "Password is too short"}) else: return jsonify({"success": False, "msg": "Not good data"})
def sign_up(): data = request.get_json() #return str(len(data['firstname'])) if validateData(data): if database_helper.find_user(data['email'], data['password']): return json.dumps({"msg": "user with that email already exists"}), 500 if validatePW(data['password']): result = database_helper.save_user(data['email'], data['password'], data['firstname'], data['familyname'], data['gender'], data['city'], data['country']) if result == True: return json.dumps({"msg": "User saved!"}), 200 else: return json.dumps({"msg": "Something went wrong!"}), 500 else: return 'Password is too short', 400 else: return 'One or more fields are empty, retry!', 400