mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2026-04-17 10:26:18 +00:00
Added toggle for signing up local clients
This commit is contained in:
@@ -1,22 +1,12 @@
|
||||
<script setup async>
|
||||
<script setup>
|
||||
import './assets/main.css'
|
||||
import NotificationList from "@/components/Notification/notificationList.vue";
|
||||
import {clientStore} from "@/stores/clientStore.js";
|
||||
import {axiosGet} from "@/utilities/request.js";
|
||||
|
||||
const store = clientStore()
|
||||
const serverInformation = axiosGet("/api/serverInformation", {})
|
||||
if (serverInformation){
|
||||
store.serverInformation = serverInformation;
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div data-bs-theme="dark" class="text-body bg-body vw-100 vh-100 bg-body">
|
||||
<div class="d-flex vw-100 p-sm-4 overflow-y-scroll innerContainer d-flex flex-column">
|
||||
<div class="mx-auto my-sm-auto position-relative"
|
||||
id="listContainer"
|
||||
>
|
||||
<div class="mx-auto my-sm-auto position-relative" id="listContainer">
|
||||
<Suspense>
|
||||
<RouterView v-slot="{ Component }">
|
||||
<Transition name="app" type="transition" mode="out-in">
|
||||
|
||||
@@ -96,7 +96,7 @@ if (route.query.Email){
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
<div>
|
||||
<div v-if="store.serverInformation.SignUp.enable">
|
||||
<hr class="my-4">
|
||||
<div class="d-flex align-items-center">
|
||||
<span class="text-muted">
|
||||
|
||||
@@ -6,43 +6,43 @@ import router from "@/router/router.js";
|
||||
import {createPinia} from "pinia";
|
||||
|
||||
import 'bootstrap/dist/js/bootstrap.bundle.js'
|
||||
import {axiosPost} from "@/utilities/request.js";
|
||||
import {axiosGet, axiosPost} from "@/utilities/request.js";
|
||||
import {clientStore} from "@/stores/clientStore.js";
|
||||
|
||||
const params = new URLSearchParams(window.location.search)
|
||||
const state = params.get('state')
|
||||
const code = params.get('code')
|
||||
|
||||
const initApp = () => {
|
||||
const initApp = async () => {
|
||||
const app = createApp(App)
|
||||
const serverInformation = await axiosGet("/api/serverInformation", {})
|
||||
app.use(createPinia())
|
||||
if (serverInformation){
|
||||
const store = clientStore()
|
||||
store.serverInformation = serverInformation.data;
|
||||
}
|
||||
app.use(router)
|
||||
app.mount("#app")
|
||||
}
|
||||
|
||||
function removeSearchString() {
|
||||
let url = new URL(window.location.href);
|
||||
url.search = ''; // Remove all query parameters
|
||||
history.replaceState({}, document.title, url.toString());
|
||||
}
|
||||
|
||||
if (state && code){
|
||||
axiosPost("/api/signin/oidc", {
|
||||
await axiosPost("/api/signin/oidc", {
|
||||
provider: state,
|
||||
code: code,
|
||||
redirect_uri: window.location.protocol + '//' + window.location.host + window.location.pathname
|
||||
}).then(data => {
|
||||
}).then(async (data) => {
|
||||
let url = new URL(window.location.href);
|
||||
url.search = '';
|
||||
history.replaceState({}, document.title, url.toString());
|
||||
|
||||
initApp()
|
||||
await initApp()
|
||||
if (!data.status){
|
||||
const store = clientStore()
|
||||
store.newNotification(data.message, 'danger')
|
||||
}
|
||||
})
|
||||
}else{
|
||||
initApp()
|
||||
await initApp()
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -50,6 +50,11 @@ const router = createRouter({
|
||||
})
|
||||
router.beforeEach(async (to, from, next) => {
|
||||
const store = clientStore()
|
||||
if (to.path === "/signup" && !store.serverInformation.SignUp.enable){
|
||||
next('/signin')
|
||||
store.newNotification("Sign up is disabled. Please contact administrator for more information", "warning")
|
||||
}
|
||||
|
||||
if (to.path === '/signout'){
|
||||
await axios.get(requestURl('/api/signout')).then(() => {
|
||||
next('/signin')
|
||||
|
||||
Reference in New Issue
Block a user