def signup(): if request.method == "POST": name = request.form["username"] mail = request.form["email"] passw = request.form["password"] ## Requested has isgned up data in dictionary put this in database db.add_user(cwd + "/tutorials.db", name, mail, passw) return render_template("signup.html") return render_template("signup.html")
def test_delete_user(app): old_len = len(db.all_users()) user = User(id=0, name="?", password="******") user = db.add_user(user) assert user.id > 0 assert db.delete_user(user.id) assert db.get_user(user.id) == None assert len(db.all_users()) == old_len
def signup_submit(): #Get User Input username = request.form['username'] password = request.form['password'] #Add User if (db.add_user(username, password)): session['username'] = request.form['username'] return redirect(url_for('homepage')) else: return redirect(url_for('signup'))
def create_user(): try: user = user_schema.loads(request.data) except ValidationError as err: return error_response(400, err.messages) if db.get_user_by_name(user.name): return error_response(400, "User already exists.") user = db.add_user(user) if user is None: return error_response(400) response = jsonify(user_schema.dump(user)) response.status_code = 201 response.headers["Location"] = url_for("api.get_user", id=user.id) return response
def signup(): form = SignupForm() if form.validate_on_submit(): encrypted_pwd = bcrypt.generate_password_hash( form.password.data).decode('utf-8') user_id = db.add_user({ 'username': form.username.data, 'password': str(encrypted_pwd), 'email': form.email.data }) user = User(form.username.data, str(encrypted_pwd), user_id, form.email.data) login_user(user, remember=True) session['userInstance'] = user.toDict() return redirect(url_for('user_profile_blueprint.get_additional_info')) return render_template('auth/signup.html', title="Sign in", form=form)
def test_add_user_with_none_argument(app): assert db.add_user(None) == None
def test_add_user_with_nonzero_id(app): user = User(id=20, name="new-user", password="******") assert db.add_user(user) == None
def test_add_user_checks_if_username_is_already_taken(app): assert db.add_user(User(id=0, name="already-taken", password="******")) is not None assert db.add_user(User(id=0, name="already-taken", password="******")) is None
def test_add_user(app): user = User(id=0, name="new-user", password="******") user = db.add_user(user) assert user.id > 0
def test_get_user(): user = {"name": "test", "password": "******", "email": "test"} response = db.add_user(user) print(response)