Commit 42069550 authored by Eliot Berriot's avatar Eliot Berriot 💬

Merge branch '339-subsonic-api-login' into 'develop'

Resolve "Login API Subsonic"

Closes #339

See merge request funkwhale/funkwhale!283
parents 002f3a95 281bef48
......@@ -19,7 +19,7 @@ def authenticate(username, password):
password = password.replace("enc:", "", 1)
password = binascii.unhexlify(password).decode("utf-8")
user = User.objects.get(
username=username, is_active=True, subsonic_api_token=password
username__iexact=username, is_active=True, subsonic_api_token=password
)
except (User.DoesNotExist, binascii.Error):
raise exceptions.AuthenticationFailed("Wrong username or password.")
......
......@@ -63,3 +63,15 @@ def test_auth_with_inactive_users(api_request, factories):
authenticator = authentication.SubsonicAuthentication()
with pytest.raises(exceptions.AuthenticationFailed):
authenticator.authenticate(request)
def test_auth_case_insensitive(api_request, factories):
user = factories["users.User"](username="Hello")
user.subsonic_api_token = "password"
user.save()
request = api_request.get("/", {"u": "hello", "p": "password"})
authenticator = authentication.SubsonicAuthentication()
u, _ = authenticator.authenticate(request)
assert user == u
Subsonic API login is now case insensitive (#339)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment