changed forbidden requests to http unauthorized
This commit is contained in:
@@ -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
|
||||
|
||||
18
create_admin_form.html
Normal file
18
create_admin_form.html
Normal file
@@ -0,0 +1,18 @@
|
||||
<html>
|
||||
<body>
|
||||
<h1>LIVE</h1>
|
||||
<form action="https://rawley.xyz/admin/user" method="post">
|
||||
<input type="text" name="username" placeholder="username"></input>
|
||||
<input type="text" name="password" placeholder="password"></input>
|
||||
<input type="text" name="api_key" placeholder="api_key"></input>
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
<h1>Localhost</h1>
|
||||
<form action="http://localhost:8080/admin/user" method="post">
|
||||
<input type="text" name="username" placeholder="username"></input>
|
||||
<input type="text" name="password" placeholder="password"></input>
|
||||
<input type="text" name="api_key" placeholder="api_key"></input>
|
||||
<button type="submit">submit</button>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
41
error.log
Normal file
41
error.log
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user