1
0
mirror of https://github.com/hrfee/jfa-go.git synced 2024-12-22 17:10:10 +00:00
jfa-go/setup.go

26 lines
667 B
Go
Raw Normal View History

2020-08-01 23:05:35 +00:00
package main
import (
"github.com/gin-gonic/gin"
)
type testReq struct {
Host string `json:"jfHost"`
Username string `json:"jfUser"`
Password string `json:"jfPassword"`
}
func (app *appContext) TestJF(gc *gin.Context) {
2020-08-01 23:05:35 +00:00
var req testReq
gc.BindJSON(&req)
tempjf, _ := newJellyfin(req.Host, "jfa-go-setup", app.version, "auth", "auth")
tempjf.noFail = true
2020-08-01 23:05:35 +00:00
_, status, err := tempjf.authenticate(req.Username, req.Password)
if !(status == 200 || status == 204) || err != nil {
app.info.Printf("Auth failed with code %d (%s)", status, err)
2020-08-01 23:05:35 +00:00
gc.JSON(401, map[string]bool{"success": false})
return
}
gc.JSON(200, map[string]bool{"success": true})
}