Merge branch '339-subsonic-api-login' into 'develop'
Resolve "Login API Subsonic" Closes #339 See merge request funkwhale/funkwhale!283
This commit is contained in:
commit
420695508b
|
@ -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
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
Subsonic API login is now case insensitive (#339)
|
Loading…
Reference in New Issue