correctly distinguish user/pass auth errors from other connectivity errors again
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user