Commit ea3f8af1 authored by ibuler's avatar ibuler

Fix pubkey auth bug

parent a75e1db9
......@@ -140,4 +140,4 @@ class UserTokenApi(APIView):
cache.set('%s_%s' % (user.id, remote_addr), token, self.expiration)
return Response({'token': token, 'id': user.id, 'username': user.username, 'name': user.name})
else:
return Response({'msg': 'Invalid password or public key or user is not active or expired'})
return Response({'msg': 'Invalid password or public key or user is not active or expired'}, status=401)
......@@ -187,8 +187,14 @@ def check_user_valid(**kwargs):
return None
if password and user.check_password(password):
return user
if public_key and user.public_key == public_key:
return user
if public_key:
public_key_saved = user.public_key.split()
if len(public_key_saved) == 1:
if public_key == public_key_saved[0]:
return user
elif len(public_key_saved) > 1:
if public_key == public_key_saved[1]:
return user
return None
......
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