예제 #1
0
def user_create():
    form = UserEditorForm()
    if form.validate_on_submit():
        current_users.add_user(form.name.data, form.password.data,
                               form.active.data)
        return redirect(url_for('wiki.admin'))
    return render_template('User/addEdit.html', form=form, create=True)
예제 #2
0
def user_create():
    form = SignupForm()
    if form.validate_on_submit():
        current_users.add_user(form.name.data, form.password.data.encode())
        user = current_users.get_user(form.name.data)
        login_user(user)
        user.set('authenticated', True)
        flash('Login successful.', 'success')
        return redirect(request.args.get("next") or url_for('wiki.index'))
    return render_template('signup.html', form=form)
예제 #3
0
def user_create():
    form = RegisterForm()
    if form.validate_on_submit():
        new_user = UserProfile('user.db')
        new_user.add_profile(form.name.data, form.fullName.data,
                             form.email.data)
        current_users.add_user(form.name.data, form.password.data, True,
                               'student', None)
        flash('Registration successful ', 'success')
        return redirect(request.args.get("next") or url_for('wiki.index'))
    return render_template('register.html', form=form)
예제 #4
0
def user_manage_create():
    user_found = False
    password_mismatch = False
    is_admin = ['admin'] if request.form.get('is_admin') else ['']
    if current_users.get_user(request.form.get('name')) is not None:
        user_found = True
        flash('Username was taken, please try again.', 'error')
    if request.form.get('password') != request.form.get('confirm_password'):
        password_mismatch = True
        flash('Those passwords didn\'t match, please try again', 'error')
    if user_found is False and password_mismatch is False:
        current_users.add_user(name=request.form.get('name'),
                               password=request.form.get('password'),
                               roles=is_admin)
    return render_template('request_completed.html')
예제 #5
0
def user_create():
    try:
        form = RegistrationForm()

        if request.method == "POST" and form.validate_on_submit():
            username = form.user.data
            password = form.password.data
            fullName = form.fullName.data
            email = form.email.data
            bio = form.bio.data
            favoriteLanguages = form.favoriteLanguages.data

            if current_users.get_user(username):
                flash("That username is already taken! please try again")
                return render_template('register.html', form=form)

            user = current_users.add_user(username,password,email,fullName,bio,favoriteLanguages)
            login_user(user)
            user.set('authenticated', True)
            flash('Thanks for registering! Welcome to Kiwi.', 'success')
            return redirect(request.args.get("next") or url_for('wiki.index'))

        return render_template('register.html',form=form)

    except Exception as e:
        return(str(e))
예제 #6
0
def user_create():
    # create a register from to transfer post signup data to backend
    form = RegisterForm()

    # check for name and password data validation
    # This check also acts as a post vs get request in a sense that
    # empty name and password fields act as a get request and non-empty
    # fields act as post request
    if form.name.data is not None and form.password.data is not None:
        user_found = False
        # checks for already existing user name
        if current_users.get_user(request.form.get('name')) is not None:
            user_found = True
            flash('Username was taken, please try again.', 'error')
        # checks for new user
        # if doesn't find in the database creates a new user.
        if user_found is False:
            current_users.add_user(name=form.name.data, password=form.password.data)
            flash('User creation successful.', 'success')
            return redirect(url_for('wiki.user_login'))
    return render_template('signup.html', form=form)