Add next value to signin page and actually use it
This commit is contained in:
parent
5cdbc4eb53
commit
2fbcb9f918
3 changed files with 16 additions and 7 deletions
|
|
@ -25,6 +25,7 @@ import Sidebar from "@/components/layout/Sidebar.vue";
|
|||
import MainContent from "@/components/layout/MainContent.vue";
|
||||
import { Session } from "@/type/api";
|
||||
import { router } from "@/route/config";
|
||||
import { useRoutes } from "@/route/use";
|
||||
import { useSessionStore } from "@/store/session";
|
||||
|
||||
const session = useSessionStore();
|
||||
|
|
@ -35,8 +36,11 @@ onMounted(() => {
|
|||
console.log("session loaded by Authenticated", session);
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log("root session not loaded", router);
|
||||
router.push("/signin");
|
||||
console.log(
|
||||
"root session not loaded, user is not authenticated",
|
||||
router.currentRoute.value.fullPath,
|
||||
);
|
||||
router.push(`/signin?next=${router.currentRoute.value.fullPath}`);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
<p class="text-muted">Please enter your credentials</p>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="next" value="none" />
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">Username</label>
|
||||
<input
|
||||
|
|
@ -112,10 +111,12 @@
|
|||
import { ref } from "vue";
|
||||
import { apiClient } from "@/client";
|
||||
import ButtonLoading from "@/components/common/ButtonLoading.vue";
|
||||
import { useQueryParam } from "@/composable/use-query-param";
|
||||
import { router } from "@/route/config";
|
||||
|
||||
const error = ref<string>("");
|
||||
const loading = ref<boolean>(false);
|
||||
const paramNext = useQueryParam("next");
|
||||
const password = ref<string>("");
|
||||
const username = ref<string>("");
|
||||
async function doLogin() {
|
||||
|
|
@ -125,7 +126,11 @@ async function doLogin() {
|
|||
password: password.value,
|
||||
username: username.value,
|
||||
});
|
||||
router.push("/");
|
||||
if (paramNext.value.value) {
|
||||
router.push(paramNext.value.value);
|
||||
} else {
|
||||
router.push("/");
|
||||
}
|
||||
} catch (e) {
|
||||
console.log("login failed", e);
|
||||
error.value = `Login failed: ${e}`;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ const mapFlyoverCamera = ref<Camera>(new Camera());
|
|||
const router = useRouter();
|
||||
const storeSite = useStoreSite();
|
||||
const selectedSiteID = ref<number>(0);
|
||||
const siteParam = useQueryParam("site");
|
||||
const paramSite = useQueryParam("site");
|
||||
const submitting = ref<boolean>(false);
|
||||
const selectedSite = computed((): Site | undefined => {
|
||||
if (!selectedSiteID.value) {
|
||||
|
|
@ -148,7 +148,7 @@ function siteSelect(id: number): void {
|
|||
return;
|
||||
}
|
||||
mapFlyoverCamera.value = new Camera(site.address.location, 20);
|
||||
siteParam.setValue(id.toString());
|
||||
paramSite.setValue(id.toString());
|
||||
console.log("selecting site", id, site);
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ onMounted(async () => {
|
|||
storeSite.fetchAll();
|
||||
});
|
||||
watch(
|
||||
siteParam.value,
|
||||
paramSite.value,
|
||||
(site_id) => {
|
||||
if (site_id) {
|
||||
const id = parseInt(site_id, 10);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue