correctly distinguish user/pass auth errors from other connectivity errors again

This commit is contained in:
Drew Weymouth
2023-11-14 17:36:07 -08:00
parent d1380d6a41
commit b7f54054d8
6 changed files with 34 additions and 10 deletions
@@ -23,6 +23,17 @@ type JellyfinServer struct {
jellyfin.Client
}
func (j *JellyfinServer) Login(user, pass string) mediaprovider.LoginResponse {
if _, err := j.Ping(); err != nil {
return mediaprovider.LoginResponse{Error: err}
}
err := j.Client.Login(user, pass)
return mediaprovider.LoginResponse{
Error: err,
IsAuthError: err != nil,
}
}
func (j *JellyfinServer) MediaProvider() mediaprovider.MediaProvider {
return newJellyfinMediaProvider(&j.Client)
}
+6 -1
View File
@@ -61,8 +61,13 @@ type Favorites struct {
Tracks []*Track
}
type LoginResponse struct {
Error error
IsAuthError bool
}
type Server interface {
Login(username, password string) error
Login(username, password string) LoginResponse
MediaProvider() MediaProvider
}
@@ -9,9 +9,13 @@ type SubsonicServer struct {
subsonicCli.Client
}
func (s *SubsonicServer) Login(username, password string) error {
func (s *SubsonicServer) Login(username, password string) mediaprovider.LoginResponse {
s.User = username
return s.Client.Authenticate(password)
err := s.Client.Authenticate(password)
return mediaprovider.LoginResponse{
Error: err,
IsAuthError: err == subsonicCli.ErrAuthenticationFailure,
}
}
func (s *SubsonicServer) MediaProvider() mediaprovider.MediaProvider {