Changes

Jump to navigation Jump to search
734 bytes added ,  07:07, 22 November 2017
no edit summary
Line 52: Line 52:  
[http://django-registration.readthedocs.org/en/latest/quickstart.html User registration]<br>
 
[http://django-registration.readthedocs.org/en/latest/quickstart.html User registration]<br>
 
[https://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/ Django registration step by step]
 
[https://devdoodles.wordpress.com/2009/02/16/user-authentication-with-django-registration/ Django registration step by step]
 +
= CBV =
 +
== CSRF Exempt ==
 +
<source lang="python">class ChromeLoginView(View):
 +
    @method_decorator(csrf_exempt)
 +
    def dispatch(self, request, *args, **kwargs):
 +
        return super(ChromeLoginView, self).dispatch(request, *args, **kwargs)
    +
    def get(self, request):
 +
        return JsonResponse({'status': request.user.is_authenticated()})
 +
 +
    def post(self, request):
 +
        username = request.POST['username']
 +
        password = request.POST['password']
 +
        user = authenticate(username=username, password=password)
 +
        if user is not None:
 +
            if user.is_active:
 +
                login(request, user)
 +
                return JsonResponse({'status': True})
 +
        return JsonResponse({'status': False})</source>
 
= Notes =
 
= Notes =
 
== Templates ==
 
== Templates ==

Navigation menu