daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest Jun 30th, 2018 97 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. {'session_key': ['Session with this Session key already exists.']}
  2.    
  3. def header_auth(request):
  4.     auth_header = request.META['HTTP_AUTHORIZATION']
  5.     encoded_credentials = auth_header.split(' ')[1]  # Removes "Basic " to isolate credentials
  6.     decoded_credentials = base64.b64decode(encoded_credentials).decode("utf-8").split(':')
  7. return decoded_credentials[0], decoded_credentials[1]
  8.  
  9.  
  10. def login_view(request):
  11.     username, password = header_auth(request)
  12.     user = authenticate(request, username=username, password=password)
  13.     if user is not None:
  14.         try:
  15.             login(request, user)
  16.             print('after login')
  17.         except Exception as e:
  18.             print('login error', e)
  19.         return HttpResponse('Authorized', status=200)
  20.     else:
  21.         return HttpResponse('Not Authorized', status=403)
  22.  
  23.  
  24. def logout_view(request):
  25.     logout(request)
  26.  
  27.  
  28. class FyndUser(AbstractUser):
  29.     company_id = models.IntegerField(unique=True)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top