mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2024-11-17 01:17:37 +00:00
Protect the prober list using cookie
This commit is contained in:
parent
c1ab301055
commit
ffaa9b37d3
2 changed files with 6 additions and 1 deletions
|
@ -1,9 +1,14 @@
|
||||||
import { apiUri } from '$lib/utils/common';
|
import { apiUri } from '$lib/utils/common';
|
||||||
|
import { goto } from '$app/navigation';
|
||||||
|
|
||||||
/** @param {import('@vincjo/datatables/remote/state')} state */
|
/** @param {import('@vincjo/datatables/remote/state')} state */
|
||||||
export const loadData = async (state) => {
|
export const loadData = async (state) => {
|
||||||
const response = await fetch(apiUri(`/api/v1/prober?${getParams(state)}`));
|
const response = await fetch(apiUri(`/api/v1/prober?${getParams(state)}`));
|
||||||
const json = await response.json();
|
const json = await response.json();
|
||||||
|
if (json.data === null) {
|
||||||
|
goto('/login');
|
||||||
|
return;
|
||||||
|
}
|
||||||
state.setTotalRows(json.data.total_rows ?? 0);
|
state.setTotalRows(json.data.total_rows ?? 0);
|
||||||
return json.data.items ?? [];
|
return json.data.items ?? [];
|
||||||
};
|
};
|
||||||
|
|
|
@ -12,7 +12,7 @@ func AppRoute(app *fiber.App) {
|
||||||
func V1Api(app *fiber.App) {
|
func V1Api(app *fiber.App) {
|
||||||
v1 := app.Group("/api/v1")
|
v1 := app.Group("/api/v1")
|
||||||
|
|
||||||
v1.Get("/prober", Prober)
|
v1.Get("/prober", CookieProtected, Prober)
|
||||||
v1.Post("/prober", CookieProtected, Prober)
|
v1.Post("/prober", CookieProtected, Prober)
|
||||||
v1.Patch("/prober/:id", CookieProtected, Prober)
|
v1.Patch("/prober/:id", CookieProtected, Prober)
|
||||||
v1.Delete("/prober/:id", CookieProtected, Prober)
|
v1.Delete("/prober/:id", CookieProtected, Prober)
|
||||||
|
|
Loading…
Reference in a new issue