Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Sebastian Dobe
committed
Jul 11, 2023
1 parent
e35ffbe
commit 4999995
Showing
15 changed files
with
746 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
<script> | ||
import {onMount} from "svelte"; | ||
import {checkAdminAccess, getSessionInfo} from "../../utils/dataFetching.js"; | ||
import {redirectToLogin} from "../../utils/helpers.js"; | ||
import BrowserCheck from "../BrowserCheck.svelte"; | ||
import Loading from "$lib/Loading.svelte"; | ||
import Button from "$lib/Button.svelte"; | ||
import AdminMain from "./AdminMain.svelte"; | ||
export let selected = 'Users'; | ||
let sessionInfo; | ||
let isAdmin = false; | ||
let mfaReqErr = false; | ||
onMount(async () => { | ||
let res = await getSessionInfo(); | ||
if (res.ok) { | ||
let body = await res.json(); | ||
let resAdmin = await checkAdminAccess(); | ||
if (resAdmin.ok) { | ||
sessionInfo = body; | ||
isAdmin = true; | ||
} else { | ||
mfaReqErr = true; | ||
sessionInfo = {}; | ||
} | ||
} else { | ||
redirectToLogin(); | ||
} | ||
}); | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Admin</title> | ||
</svelte:head> | ||
|
||
<BrowserCheck> | ||
{#if !sessionInfo && !mfaReqErr} | ||
<Loading/> | ||
{:else if mfaReqErr} | ||
<div class="noAdmin"> | ||
<div class="text"> | ||
A rauthy admin account must have <b>MFA enabled.</b><br> | ||
Please navigate to your <b>account</b> and activate MFA.<br> | ||
Afterwards, you need to do a logout and log back in. | ||
</div> | ||
<Button on:click={() => window.location.href = '/auth/v1/account'}>ACCOUNT</Button> | ||
<!-- <Button on:click={() => window.location.href = '/auth/v1/account.html'}>ACCOUNT</Button>--> | ||
</div> | ||
{:else if !isAdmin} | ||
<div class="noAdmin"> | ||
<div class="text"> | ||
You are not assigned to the <b>rauthy_admin</b> role and have no access to the admin panel. | ||
</div> | ||
<Button on:click={() => window.location.href = '/auth/v1/'}>GO BACK</Button> | ||
</div> | ||
{:else} | ||
<AdminMain bind:sessionInfo bind:selected/> | ||
{/if} | ||
</BrowserCheck> | ||
|
||
<style> | ||
.noAdmin { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.text { | ||
margin: 10px; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,74 +1,5 @@ | ||
<script> | ||
import {onMount} from "svelte"; | ||
import {checkAdminAccess, getSessionInfo} from "../../utils/dataFetching.js"; | ||
import Loading from "../../components/Loading.svelte"; | ||
import {redirectToLogin} from "../../utils/helpers.js"; | ||
import AdminMain from "../../components/admin/AdminMain.svelte"; | ||
import Button from "$lib/Button.svelte"; | ||
import BrowserCheck from "../../components/BrowserCheck.svelte"; | ||
let sessionInfo; | ||
let isAdmin = false; | ||
let mfaReqErr = false; | ||
onMount(async () => { | ||
let res = await getSessionInfo(); | ||
if (res.ok) { | ||
let body = await res.json(); | ||
let resAdmin = await checkAdminAccess(); | ||
if (resAdmin.ok) { | ||
sessionInfo = body; | ||
isAdmin = true; | ||
} else { | ||
mfaReqErr = true; | ||
sessionInfo = {}; | ||
} | ||
} else { | ||
redirectToLogin(); | ||
} | ||
}); | ||
import AdminMainPre from "../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<svelte:head> | ||
<title>Rauthy Admin</title> | ||
</svelte:head> | ||
|
||
<BrowserCheck> | ||
{#if !sessionInfo && !mfaReqErr} | ||
<Loading/> | ||
{:else if mfaReqErr} | ||
<div class="noAdmin"> | ||
<div class="text"> | ||
A rauthy admin account must have <b>MFA enabled.</b><br> | ||
Please navigate to your <b>account</b> and activate MFA.<br> | ||
Afterwards, you need to do a logout and log back in. | ||
</div> | ||
<Button on:click={() => window.location.href = '/auth/v1/account'}>ACCOUNT</Button> | ||
<!-- <Button on:click={() => window.location.href = '/auth/v1/account.html'}>ACCOUNT</Button>--> | ||
</div> | ||
{:else if !isAdmin} | ||
<div class="noAdmin"> | ||
<div class="text"> | ||
You are not assigned to the <b>rauthy_admin</b> role and have no access to the admin panel. | ||
</div> | ||
<Button on:click={() => window.location.href = '/auth/v1/'}>GO BACK</Button> | ||
</div> | ||
{:else} | ||
<AdminMain bind:sessionInfo/> | ||
{/if} | ||
</BrowserCheck> | ||
|
||
<style> | ||
.noAdmin { | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
.text { | ||
margin: 10px; | ||
} | ||
</style> | ||
<AdminMainPre selected="Users"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Users"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Clients"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Config"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Docs"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Groups"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Roles"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Scopes"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Sessions"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<script> | ||
import AdminMainPre from "../../../components/admin/AdminMainPre.svelte"; | ||
</script> | ||
|
||
<AdminMainPre selected="Users"/> |
Oops, something went wrong.