mirror of
https://github.com/ultrasn0w/huso.git
synced 2025-12-13 17:29:54 +01:00
Maintenance
This commit is contained in:
21
ober.go
21
ober.go
@@ -19,8 +19,7 @@ func RunWebserv() {
|
||||
r.GET("/api/watch/{user?}", WatchGet)
|
||||
r.POST("/api/register", Register)
|
||||
r.POST("/api/watch/{user}", WatchPost)
|
||||
r.PATCH("/api/watch/{user}", Start)
|
||||
r.DELETE("/api/watch/{user}", Start)
|
||||
r.DELETE("/api/watch/{user}", WatchDelete)
|
||||
log.Fatal(fasthttp.ListenAndServe(":"+strconv.Itoa(*webServerPort), r.Handler))
|
||||
}
|
||||
|
||||
@@ -197,6 +196,7 @@ func WatchPost(ctx *fasthttp.RequestCtx) {
|
||||
return
|
||||
}
|
||||
anime.Users = animeData.Users
|
||||
fmt.Printf("%+v\n", anime)
|
||||
}
|
||||
|
||||
// TODO
|
||||
@@ -221,6 +221,23 @@ func WatchPost(ctx *fasthttp.RequestCtx) {
|
||||
}
|
||||
}
|
||||
|
||||
func WatchDelete(ctx *fasthttp.RequestCtx) {
|
||||
auth := ctx.Request.Header.Peek("X-HUSO-AUTH")
|
||||
if ctx.UserValue("user") == nil || auth == nil || string(auth) == "" || string(ctx.Request.Header.ContentType()) != "application/json" {
|
||||
ctx.SetStatusCode(fasthttp.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
username := fmt.Sprintf("%s", ctx.UserValue("user"))
|
||||
legit, userId := GheddoAuth(username, string(auth))
|
||||
if !legit {
|
||||
ctx.SetStatusCode(fasthttp.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
// TODO
|
||||
fmt.Printf("%+v\n", userId)
|
||||
}
|
||||
|
||||
func GheddoAuth(username, auth string) (bool, int64) {
|
||||
user, err := ReadUser(username)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user