AccessRestricted.svelte 813 Bytes
Newer Older
Emmanuel Raviart's avatar
Emmanuel Raviart committed
1
2
3
<script lang="ts">
  import { stores } from "@sapper/app"

4
  import type { ZammadUser } from "../zammad"
5

Emmanuel Raviart's avatar
Emmanuel Raviart committed
6
7
  const { session } = stores()

8
  $: user = $session.user as ZammadUser | undefined
Emmanuel Raviart's avatar
Emmanuel Raviart committed
9

10
  $: roles = user?.roles
Emmanuel Raviart's avatar
Emmanuel Raviart committed
11
12
13
14
15
16
17
18
19
20
21
22
23
</script>

{#if user == null}
  <div class="card ~warning !high">
    <strong>Authentication required!</strong>
    You must sign in to access to this page.
  </div>
{:else}
  <div class="card ~critical !high">
    <p>
      <strong>Access restricted!</strong>
      Your credentials don't allow you to access to this page.
    </p>
24
    {#if roles == null}
Emmanuel Raviart's avatar
Emmanuel Raviart committed
25
26
      <i class="italic">You don't have any role.</i>
    {:else}
27
28
29
30
31
32
      <p>Your roles:</p>
      <ul class="list-disc list-inside">
        {#each roles as role}
          <li>{role}</li>
        {/each}
      </ul>
Emmanuel Raviart's avatar
Emmanuel Raviart committed
33
34
35
    {/if}
  </div>
{/if}