tomahawk-player / tomahawk-resolvers

Resolver plugins for Tomahawk Player
216 stars 113 forks source link

Ampache Resolver - Better Error Handling #115

Open AshotN opened 8 years ago

AshotN commented 8 years ago

I've been spending some time trying to figure out why my ownCloud(Ampache) server will not authenticate. The resolver kept saying "Username or password incorrect." This led me to believe that I was just doing something wrong with ownCloud. But after several attempts I decided to dive into the code.

if (typeof error != 'undefined' && error.getAttribute("code") == "403") {
    return TomahawkConfigTestResultType.InvalidAccount;
} else {
    return TomahawkConfigTestResultType.InvalidCredentials;
}

The code only checked for a 403 and that's it... what I was getting instead was a 401

<error code=​"401">​Invalid Login - timestamp is in future​</error>​

I've just started reading through the code and I'm not sure what would be a good return value since the documentation suggests avoiding custom messages. I think resolvers should go through expected errors and then output the error itself to the user as a final resort. Much better than misleading errors.

EDIT:

Also ownCloud seems to be aware of this timestamp problem

// TODO - while testing with tomahawk it sometimes is $currenttime+1 ... needs further investigation
    if($providedTime > $currentTime + 100) {
        throw new AmpacheException('Invalid Login - timestamp is in future', 401);
    }

https://github.com/owncloud/music/blob/master/controller/ampachecontroller.php

EDIT 2: I got my ampache to work... my Linux system clock was somehow wrong.