Moved admin to own sub route
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c3f683b030
commit
980d0ce019
|
@ -30,7 +30,7 @@ function updateCoins(id) {
|
||||||
$('#coins_container_' + id).addClass('disabled');
|
$('#coins_container_' + id).addClass('disabled');
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/update',
|
url: '/admin/update',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: 'id=' + id + '&addcoins=' + addcoins,
|
data: 'id=' + id + '&addcoins=' + addcoins,
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
|
@ -64,7 +64,7 @@ function deleteKonfi(id) {
|
||||||
},
|
},
|
||||||
onApprove : function() {
|
onApprove : function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/delete',
|
url: '/admin/delete',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: 'id=' + id,
|
data: 'id=' + id,
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
|
@ -97,7 +97,7 @@ function deleteGemeinde(id) {
|
||||||
},
|
},
|
||||||
onApprove : function() {
|
onApprove : function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/delete',
|
url: '/admin/delete',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: 'id=' + id,
|
data: 'id=' + id,
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
|
@ -124,7 +124,7 @@ $('.ui.kofiadd.modal')
|
||||||
onApprove : function() {
|
onApprove : function() {
|
||||||
$('.loader').addClass('active');
|
$('.loader').addClass('active');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/add',
|
url: '/admin/add',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: 'name=' + $('#name').val() + '&gemeinde=' + $('#gemeinde').val(),
|
data: 'name=' + $('#name').val() + '&gemeinde=' + $('#gemeinde').val(),
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
|
@ -152,7 +152,7 @@ $('.ui.gemeindeadd.modal')
|
||||||
onApprove : function() {
|
onApprove : function() {
|
||||||
$('.loader').addClass('active');
|
$('.loader').addClass('active');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: '/add',
|
url: '/admin/add',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: 'name=' + $('#name').val() + '&konfis=' + $('#konfis').val(),
|
data: 'name=' + $('#name').val() + '&konfis=' + $('#konfis').val(),
|
||||||
success: function (msg) {
|
success: function (msg) {
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
const source = new EventSource('/events');
|
||||||
|
source.onmessage = function(e) {
|
||||||
|
console.log(e)
|
||||||
|
};
|
||||||
|
|
||||||
|
/*
|
||||||
setInterval(function() {
|
setInterval(function() {
|
||||||
$.getJSON('/list', function (data) {
|
$.getJSON('/list', function (data) {
|
||||||
$( "#konfis" ).html('');
|
$( "#konfis" ).html('');
|
||||||
|
@ -17,4 +23,5 @@ setInterval(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
*/
|
||||||
|
|
|
@ -39,7 +39,6 @@ func RegisterRoutes(e *echo.Echo) {
|
||||||
e.Static("/assets", "assets")
|
e.Static("/assets", "assets")
|
||||||
|
|
||||||
//Routes
|
//Routes
|
||||||
e.GET("/admin", adminHandler)
|
|
||||||
e.GET("/", showList)
|
e.GET("/", showList)
|
||||||
|
|
||||||
e.POST("/login", login)
|
e.POST("/login", login)
|
||||||
|
@ -72,15 +71,17 @@ func RegisterRoutes(e *echo.Echo) {
|
||||||
e.GET("/list", handler.ReadAll)
|
e.GET("/list", handler.ReadAll)
|
||||||
|
|
||||||
// Routes with auth
|
// Routes with auth
|
||||||
a := e.Group("")
|
a := e.Group("/admin")
|
||||||
a.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
a.Use(func(next echo.HandlerFunc) echo.HandlerFunc {
|
||||||
return func(c echo.Context) error {
|
return func(c echo.Context) error {
|
||||||
if !isLoggedIn(c) {
|
// Only check if the user is logged in if the path is not /admin, to still be able to show the login page
|
||||||
|
if c.Path() != "/admin" && !isLoggedIn(c) {
|
||||||
return echo.NewHTTPError(http.StatusForbidden, "Login first.")
|
return echo.NewHTTPError(http.StatusForbidden, "Login first.")
|
||||||
}
|
}
|
||||||
return next(c)
|
return next(c)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
a.GET("", adminHandler)
|
||||||
a.POST("/update", handler.Update)
|
a.POST("/update", handler.Update)
|
||||||
a.POST("/delete", handler.Delete)
|
a.POST("/delete", handler.Delete)
|
||||||
a.POST("/add", handler.Create)
|
a.POST("/add", handler.Create)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user