mirror of
https://github.com/nikdoof/test-auth.git
synced 2025-12-14 06:42:16 +00:00
Fixes for issues in API calls, more error checking
This commit is contained in:
@@ -57,16 +57,16 @@ class LoginHandler(BaseHandler):
|
||||
except (User.DoesNotExist, ValueError):
|
||||
return rc.NOT_HERE
|
||||
|
||||
if 'user' in request.GET:
|
||||
if request.GET.get('user', None):
|
||||
try:
|
||||
u = User.objects.get(username=request.GET['user'])
|
||||
except User.DoesNotExist:
|
||||
return rc.NOT_HERE
|
||||
|
||||
d = { 'auth': 'ok', 'id': u.id, 'username': u.username,
|
||||
'password': u.password, 'email': u.email, 'groups': u.groups.all() }
|
||||
'email': u.email, 'groups': u.groups.all() }
|
||||
|
||||
if request.GET['pass'] == user.password:
|
||||
if request.GET.get('pass', None) and request.GET['pass'] == u.password:
|
||||
return d
|
||||
|
||||
return { 'auth': 'failed' }
|
||||
|
||||
@@ -10,7 +10,7 @@ class AuthAPIKey(models.Model):
|
||||
key = models.CharField("API Key", max_length=200)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not key or key = '':
|
||||
if not key or key == '':
|
||||
self.key = uuid.uuid4()
|
||||
|
||||
models.Model.save(self, *args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user