mirror of
https://github.com/hrfee/jfa-go.git
synced 2024-12-22 17:10:10 +00:00
Harvey Tindall
8e45ecb214
controls how old the Jellyfin user cache can be before refetching. defaults to 30 minutes.
27 lines
774 B
Go
27 lines
774 B
Go
package main
|
|
|
|
import (
|
|
"github.com/gin-gonic/gin"
|
|
"github.com/hrfee/jfa-go/common"
|
|
"github.com/hrfee/jfa-go/jfapi"
|
|
)
|
|
|
|
type testReq struct {
|
|
Host string `json:"jfHost"`
|
|
Username string `json:"jfUser"`
|
|
Password string `json:"jfPassword"`
|
|
}
|
|
|
|
func (app *appContext) TestJF(gc *gin.Context) {
|
|
var req testReq
|
|
gc.BindJSON(&req)
|
|
tempjf, _ := jfapi.NewJellyfin(req.Host, "jfa-go-setup", app.version, "auth", "auth", common.NewTimeoutHandler("authJF", req.Host, true), 30)
|
|
_, 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)
|
|
gc.JSON(401, map[string]bool{"success": false})
|
|
return
|
|
}
|
|
gc.JSON(200, map[string]bool{"success": true})
|
|
}
|