예제 #1
0
def add_user():

    new_user = {
        "first_name": request.form['first_name'],
        "last_name": request.form['last_name'],
        "email": request.form['email']
    }

    User.add_user(new_user)

    return redirect("/users")
예제 #2
0
파일: users.py 프로젝트: Davebreaux/Class
def register():
    print(request.form)
    if not User.validate(request.form):
        return redirect('/')
    if not EMAIL_REGEX.match(request.form['email']):
        flash("Invalid Email Address")
        return redirect('/')
    pass_check = re.findall('\d.*[A-Z]|[A-Z].*\d', request.form['password'])
    if not pass_check:
        flash('Password must contain one uppercase letter or number')
        return redirect('/')
    pw_hash = bcrypt.generate_password_hash(request.form["password"])
    data = {
        "email": request.form['email'],
        "password": pw_hash,
        "first_name": request.form['first_name'],
        "last_name": request.form['last_name'],
    }
    if 'spam' in request.form:
        data['spam_ok'] = 1
    else:
        print('nope')
        data['spam_ok'] = 0

    if not User.is_unique(data):
        flash("Email address already in use.")
        return redirect('/')

    new_user = User.add_user(data)
    flash("You have successfully registered")
    session['user_id'] = new_user
    session['email'] = data['email']
    return redirect('/success')
예제 #3
0
def add_user():
    User.add_user(request.form)
    return redirect('/friendships')