diff --git a/controllers/admin.go b/controllers/admin.go index fbabce7..08ab30a 100644 --- a/controllers/admin.go +++ b/controllers/admin.go @@ -22,7 +22,7 @@ func AdminOnly() gin.HandlerFunc { var status uint = http.StatusOK k, err := c.Cookie("admin_key") if err != nil { - status = http.StatusForbidden + status = http.StatusUnauthorized } fmt.Println(k) if k == key && status == http.StatusOK { @@ -44,12 +44,12 @@ func RegisterAdminGroup(r *gin.RouterGroup) { func HandleLogin(c *gin.Context) { if att[c.ClientIP()] > 5 { - c.HTML(http.StatusForbidden, "forbidden.tmpl", models.Page{Title: " | forbidden"}) + c.HTML(http.StatusUnauthorized, "forbidden.tmpl", models.Page{Title: " | forbidden"}) return } err := c.Request.ParseForm() if err != nil { - c.HTML(http.StatusForbidden, "forbidden.tmpl", models.Page{Title: " | forbidden"}) + c.HTML(http.StatusUnauthorized, "forbidden.tmpl", models.Page{Title: " | forbidden"}) return } f := c.Request.Form diff --git a/create_admin_form.html b/create_admin_form.html new file mode 100644 index 0000000..5c4a0d5 --- /dev/null +++ b/create_admin_form.html @@ -0,0 +1,18 @@ + + +

LIVE

+
+ + + + +
+

Localhost

+
+ + + + +
+ + diff --git a/error.log b/error.log new file mode 100644 index 0000000..890a8cb --- /dev/null +++ b/error.log @@ -0,0 +1,41 @@ +[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached. + +[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production. + - using env: export GIN_MODE=release + - using code: gin.SetMode(gin.ReleaseMode) + +[GIN-debug] Loaded HTML Templates (19): + - admin_success_redirect.tmpl + - footer_no_banners.tmpl + - + - blog_post.tmpl + - header.tmpl + - wip.tmpl + - contact.tmpl + - footer.tmpl + - nav.tmpl + - not_found.tmpl + - resume.tmpl + - login.tmpl + - post_success.tmpl + - session_revoked.tmpl + - blog.tmpl + - create_post.tmpl + - forbidden.tmpl + - index.tmpl + - internal_server_error.tmpl + +[GIN-debug] GET /blog/ --> gitlab.com/rawleyifowler/site-rework/controllers.(*BlogController).IndexBlogPage-fm (4 handlers) +[GIN-debug] GET /blog/post/:url --> gitlab.com/rawleyifowler/site-rework/controllers.(*BlogController).IndividualBlogPage-fm (4 handlers) +[GIN-debug] GET /admin/ --> gitlab.com/rawleyifowler/site-rework/utils.ServePage.func1 (5 handlers) +[GIN-debug] POST /admin/login --> gitlab.com/rawleyifowler/site-rework/controllers.(*AdminController).AdminLogin-fm (5 handlers) +[GIN-debug] GET /admin/post --> gitlab.com/rawleyifowler/site-rework/utils.ServePage.func1 (6 handlers) +[GIN-debug] POST /admin/post --> gitlab.com/rawleyifowler/site-rework/controllers.(*AdminController).CRUDPost-fm (6 handlers) +[GIN-debug] POST /admin/user --> gitlab.com/rawleyifowler/site-rework/controllers.(*AdminController).CreateAdmin-fm (5 handlers) +[GIN-debug] GET / --> gitlab.com/rawleyifowler/site-rework/utils.ServePage.func1 (4 handlers) +[GIN-debug] GET /resume --> gitlab.com/rawleyifowler/site-rework/utils.ServePage.func1 (4 handlers) +[GIN-debug] GET /contact --> gitlab.com/rawleyifowler/site-rework/utils.ServePage.func1 (4 handlers) +[GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value. +Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. +[GIN-debug] Listening and serving HTTP on :8080 +[GIN-debug] [ERROR] listen tcp :8080: bind: address already in use