diff --git a/IT_asset_management/app/routes/settings.py b/IT_asset_management/app/routes/settings.py index 07188cf..e621dac 100644 --- a/IT_asset_management/app/routes/settings.py +++ b/IT_asset_management/app/routes/settings.py @@ -15,35 +15,6 @@ def index(): return render_template('settings/index.html', admins=admins, config=current_app.config) -@bp.route('/admin/new', methods=['POST']) -@login_required -@admin_required -def create_admin(): - username = request.form.get('username', '').strip() - email = request.form.get('email', '').strip() - full_name = request.form.get('full_name', '').strip() - password = request.form.get('password', '') - role = request.form.get('role', 'readonly') - - if role not in ('admin', 'editor', 'readonly'): - role = 'readonly' - - if not username or not email or not password: - flash('Username, email and password are required.', 'danger') - return redirect(url_for('settings.index')) - - if AdminUser.query.filter_by(username=username).first(): - flash(f'Username "{username}" is already taken.', 'danger') - return redirect(url_for('settings.index')) - - admin = AdminUser(username=username, email=email, full_name=full_name, role=role) - admin.set_password(password) - db.session.add(admin) - db.session.commit() - flash(f'User "{username}" created with role "{role}".', 'success') - return redirect(url_for('settings.index')) - - @bp.route('/admin//toggle', methods=['POST']) @login_required @admin_required diff --git a/IT_asset_management/app/templates/settings/index.html b/IT_asset_management/app/templates/settings/index.html index a6aa78f..1665ad4 100644 --- a/IT_asset_management/app/templates/settings/index.html +++ b/IT_asset_management/app/templates/settings/index.html @@ -87,41 +87,14 @@ - + {% if current_user.is_admin %} {% endif %}