Display Next-Prev Page according to the params

I’ve a next-prev-page.html layouts.

I would like to display or navigate users to the related pages where they have a permission.I’ve a if statement in base.html, where I’m checking the audience params that I set in config file to display page or display “Access Denied”. But I can not able to do this for my nex-prev.page.

Although next page is not accessible, ı’m able to navigate next page which displays to me “Access Denied”. Instead of this, I would like to navigate the next/previous page where I can see or have permission which not display "Access Denied.What ı mean, when I press next/page, it should navigates to me only the pages that ı’ve a permission

How can I achieve this solution?

next-prev.page.html

<div class="d-flex justify-content-center">
    {{- with ($.Scratch.Get "prevPage") -}}
    <a class="p-1 mr-3 d-inline-block text-white" href="{{.RelPermalink}}" title="{{.Title}}"><i
            class="fas fa-chevron-left p-1"></i>{{.Title}}</a>
    {{ end -}}
    {{- with ($.Scratch.Get "nextPage") -}}
    <a class="p-1 ml-3 d-inline-block text-white text-right" href="{{.RelPermalink}}"
        title="{{.Title}}">{{.Title}}<i class="fas fa-chevron-right p-1"></i></a>
    {{- end }}
</div>

base.html

<main class="col-12 col-md-9 col-xl-8 pl-md-5" role="main">
  {{- if .Params.audience }}
  {{- if in .Site.Params.audience (.Params.audience) }}
  {{ block "main" . }}{{ end }}
  <div class="row">
    <div class="position-relative mx-auto col-lg-9">
      {{ partial "next-prev-page.html" . }}
    </div>
  </div>
  {{- else }}
  <h1>Access Denied</h1>
  {{- end }}
  {{- else }}
  {{ block "main" . }}{{ end }}
  {{- end }}