예제 #1
0
def user_delete(name):
    um = get_users()
    if "admin" in current_user.data.get('roles'):
        um.delete_user(name)
        flash("User successfully deleted.", 'success')
    else:
        flash("Unable to delete user. You do not have permission.", 'error')
    return redirect(url_for('wiki.user_index'))
예제 #2
0
def user_changerole(name, role):
    um = get_users()
    if "admin" in current_user.data.get('roles'):
        um.update_role(name, role)
        flash("User role successfully changed.", 'success')
    else:
        flash("Unable to change user role. You do not have permission.", 'error')
    return redirect(url_for('wiki.user_index'))
예제 #3
0
def addUser():
    form = addUserForm()
    if form.validate_on_submit():
        name = form.name.data
        pword = form.pword.data
        role = request.form['role']
        um = get_users()
        add = um.add_user(name, pword, role)
        if not add:
            flash('Username already exists', 'error')
        else:
            flash('User created successfully', 'success')
        return redirect(request.args.get("next") or url_for('wiki.index'))
    return render_template('addUser.html', form=form)
예제 #4
0
def user_edit(user_id):
    user_manager = get_users()
    user = user_manager.get_user(user_id)
    form = UserEditorForm(name=user.get("name"),
                          password=user.get("password"),
                          active=user.get("active"))

    if form.validate_on_submit():
        user.set("name", form.name.data)
        user.set("password", form.password.data)
        user.set("active", form.active.data)
        user.save()

        return redirect(url_for('wiki.admin'))
    return render_template('User/addEdit.html', form=form, create=False)
예제 #5
0
def user_self_delete(user_id):
    get_users().delete_user(user_id)
    return redirect(url_for('wiki.login'))
예제 #6
0
def user_delete(user_id):
    get_users().delete_user(user_id)
    return redirect(url_for('wiki.admin'))