Skip to content

Commit 9a938cb

Browse files
committed
Added a call to login for wrapped view, corrected a logic error, added is_active check
1 parent fa4e9e8 commit 9a938cb

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

codespeed/auth.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22
from functools import wraps
3-
from django.contrib.auth import authenticate
3+
from django.contrib.auth import authenticate, login
44
from django.http import HttpResponse, HttpResponseForbidden
55
from django.conf import settings
66
from base64 import b64decode
@@ -24,9 +24,10 @@ def _decorator(request, *args, **kwargs):
2424
if authmeth.lower() == 'basic':
2525
username, password = decode_basic_auth(auth)
2626
user = authenticate(username=username, password=password)
27-
if user is None:
27+
if user is not None and user.is_active:
2828
logging.info(
2929
'Authentication succeeded for {}'.format(username))
30+
login(request, user)
3031
allowed = True
3132
else:
3233
return HttpResponseForbidden()

0 commit comments

Comments
 (0)