mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 15:10:27 +00:00
Merge pull request #1378 from raunz/global_search_for_all_users
Global Search available for all users
This commit is contained in:
commit
f4f1f31575
@ -2021,7 +2021,6 @@ def delete_template(template):
|
||||
|
||||
@admin_bp.route('/global-search', methods=['GET'])
|
||||
@login_required
|
||||
@operator_role_required
|
||||
def global_search():
|
||||
if request.method == 'GET':
|
||||
domains = []
|
||||
@ -2033,6 +2032,22 @@ def global_search():
|
||||
server = Server(server_id='localhost')
|
||||
results = server.global_search(object_type='all', query=query)
|
||||
|
||||
# Filter results to domains to which the user has access permission
|
||||
if current_user.role.name not in [ 'Administrator', 'Operator' ]:
|
||||
allowed_domains = db.session.query(Domain) \
|
||||
.outerjoin(DomainUser, Domain.id == DomainUser.domain_id) \
|
||||
.outerjoin(Account, Domain.account_id == Account.id) \
|
||||
.outerjoin(AccountUser, Account.id == AccountUser.account_id) \
|
||||
.filter(
|
||||
db.or_(
|
||||
DomainUser.user_id == current_user.id,
|
||||
AccountUser.user_id == current_user.id
|
||||
)) \
|
||||
.with_entities(Domain.name) \
|
||||
.all()
|
||||
allowed_domains = [value for value, in allowed_domains]
|
||||
results = list(filter(lambda r: r['zone_id'][:-1] in allowed_domains, results))
|
||||
|
||||
# Format the search result
|
||||
for result in results:
|
||||
if result['object_type'] == 'zone':
|
||||
|
@ -85,6 +85,12 @@
|
||||
<p>Dashboard</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_global_search' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.global_search') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-search"></i>
|
||||
<p>Global Search</p>
|
||||
</a>
|
||||
</li>
|
||||
{% if SETTING.get('allow_user_create_domain') or current_user.role.name in ['Administrator', 'Operator'] %}
|
||||
<li class="{{ 'nav-item active' if active_page == 'nav-item new_domain' else 'nav-item' }}">
|
||||
<a href="{{ url_for('domain.add') }}" class="nav-link">
|
||||
@ -115,12 +121,6 @@
|
||||
<p>Server Configuration</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_global_search' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.global_search') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-search"></i>
|
||||
<p>Global Search</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_history' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.history') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-timeline"></i>
|
||||
|
Loading…
Reference in New Issue
Block a user