Changes
Jump to navigation
Jump to search
← Older edit
Newer edit →
Django
(view source)
Revision as of 07:07, 22 November 2017
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 ==
Rafahsolis
Bureaucrats
,
Administrators
2,306
edits
Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
Page
Discussion
Variants
Views
Read
View source
View history
More
Search
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Tools
Special pages
Printable version