|
|
@ -1,10 +1,13 @@
|
|
|
|
package main
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
"sync"
|
|
|
|
"sync"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
|
|
|
"github.com/hrfee/jfa-go/logger"
|
|
|
|
lm "github.com/hrfee/jfa-go/logmessages"
|
|
|
|
lm "github.com/hrfee/jfa-go/logmessages"
|
|
|
|
"github.com/hrfee/mediabrowser"
|
|
|
|
"github.com/hrfee/mediabrowser"
|
|
|
|
"github.com/lithammer/shortuuid/v3"
|
|
|
|
"github.com/lithammer/shortuuid/v3"
|
|
|
@ -53,9 +56,11 @@ type NewUserData struct {
|
|
|
|
func (app *appContext) NewUserPostVerification(p NewUserParams) (out NewUserData, pendingTasks *sync.WaitGroup) {
|
|
|
|
func (app *appContext) NewUserPostVerification(p NewUserParams) (out NewUserData, pendingTasks *sync.WaitGroup) {
|
|
|
|
pendingTasks = &sync.WaitGroup{}
|
|
|
|
pendingTasks = &sync.WaitGroup{}
|
|
|
|
// Some helper functions which will behave as our app.info/error/debug
|
|
|
|
// Some helper functions which will behave as our app.info/error/debug
|
|
|
|
|
|
|
|
// And make sure we capture the correct caller location.
|
|
|
|
deferLogInfo := func(s string, args ...any) {
|
|
|
|
deferLogInfo := func(s string, args ...any) {
|
|
|
|
|
|
|
|
loc := logger.Lshortfile(2)
|
|
|
|
out.Log = func() {
|
|
|
|
out.Log = func() {
|
|
|
|
app.info.Printf(s, args)
|
|
|
|
app.info.PrintfNoFile(loc+" "+s, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* deferLogDebug := func(s string, args ...any) {
|
|
|
|
/* deferLogDebug := func(s string, args ...any) {
|
|
|
@ -64,11 +69,19 @@ func (app *appContext) NewUserPostVerification(p NewUserParams) (out NewUserData
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} */
|
|
|
|
} */
|
|
|
|
deferLogError := func(s string, args ...any) {
|
|
|
|
deferLogError := func(s string, args ...any) {
|
|
|
|
|
|
|
|
loc := logger.Lshortfile(2)
|
|
|
|
out.Log = func() {
|
|
|
|
out.Log = func() {
|
|
|
|
app.err.Printf(s, args)
|
|
|
|
app.err.PrintfNoFile(loc+" "+s, args...)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if strings.ContainsRune(p.Req.Username, '+') {
|
|
|
|
|
|
|
|
deferLogError(lm.FailedCreateUser, lm.Jellyfin, p.Req.Username, fmt.Sprintf(lm.InvalidChar, '+'))
|
|
|
|
|
|
|
|
out.Status = 400
|
|
|
|
|
|
|
|
out.Message = "errorSpecialSymbols"
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
existingUser, _ := app.jf.UserByName(p.Req.Username, false)
|
|
|
|
existingUser, _ := app.jf.UserByName(p.Req.Username, false)
|
|
|
|
if existingUser.Name != "" {
|
|
|
|
if existingUser.Name != "" {
|
|
|
|
out.Message = lm.UserExists
|
|
|
|
out.Message = lm.UserExists
|
|
|
|