{ "info": { "author": "Stefan Foulis", "author_email": "stefan@foulis.ch", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP" ], "description": "=============================\ndjango-class-based-auth-views\n=============================\n\nrelated packages\n================\n\n* `django-password-reset `_ has class based views to reset\n forgotten passwords by email confirmation.\n\n\nA reimplementation of ``django.contrib.auth.views`` as class based views. Hopefully at some point this project or\nsomething similar will make it into django proper.\n\nCurrently ``LoginView`` and ``LogoutView`` are implemented.\n\n\nInstallation\n============\n\n::\n\n pip install django-class-auth-views\n\n\nBasic usage\n===========\n\nInstead of including ``django.contrib.auth.login`` into your ``urls.py``, just use the one provided by this project.\n``urls.py``::\n\n from class_based_auth_views.views import LoginView, LogoutView\n urlpatterns = patterns('',\n url(r'^login/$', LoginView.as_view(form_class=EmailAsUsernameAuthenticationForm), name=\"login\"),\n url(r'^logout/$', LogoutView.as_view(), name=\"logout\"),\n )\n\n\nBe aware that the logout view requires a ``POST`` to actually logout. So the ``registration/logout.html`` template\nshould contain a form with a submit button.\n\n\nExtending LoginView Example\n===========================\n\nNow that LoginView is based on generic class based views it is much easier to extend. Say you need to implement a\n2 step login procedure with a one time password::\n\n\n from django.contrib.auth import login\n\n class PhaseOneLoginView(LoginView):\n def form_valid(self, form):\n \"\"\"\n Forces superusers to login in a 2 step process (One Time Password). Other users are logged in normally\n \"\"\"\n user = form.get_user()\n if user.is_superuser:\n self.save_user(user)\n return HttpResponseRedirect(self.get_phase_two_url())\n else:\n login(self.request, user)\n return HttpResponseRedirect(self.get_success_url())\n\n def get_phase_two_url(self):\n return reverse('phase_two_login')\n\n def save_user(self, user):\n self.request.session['otp_user'] = user\n\n\n class PhaseTwoLoginView(FormView):\n form_class = OTPTokenForm\n\n def get_user(self):\n return self.request.session.get('otp_user', None)\n\n def clean_user(self):\n if 'otp_user' in self.request.session:\n del self.request.session['otp_user']\n\n def form_valid(self, form):\n code = form.cleaned_data.get('code')\n user = self.get_user()\n login(request, user)", "description_content_type": "", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/druids/django-class-based-auth-views", "keywords": "", "license": "BSD", "maintainer": "Stefan Foulis", "maintainer_email": "stefan@foulis.ch", "name": "django-class-auth-views", "package_url": "https://pypi.org/project/django-class-auth-views/", "platform": "OS Independent", "project_url": "https://pypi.org/project/django-class-auth-views/", "project_urls": { "Homepage": "https://github.com/druids/django-class-based-auth-views" }, "release_url": "https://pypi.org/project/django-class-auth-views/1.0.2/", "requires_dist": null, "requires_python": "", "summary": "A reimplementation of django.contrib.auth.views as class based views.", "version": "1.0.2" }, "last_serial": 5655988, "releases": { "1.0.0": [ { "comment_text": "", "digests": { "md5": "7eab455671d313fc52840c541168d265", "sha256": "303b8bb8721e224c2e3ef40ee93fcc6657d526b1e3556de8afe4179527302d73" }, "downloads": -1, "filename": "django-class-auth-views-1.0.0.tar.gz", "has_sig": false, "md5_digest": "7eab455671d313fc52840c541168d265", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5805, "upload_time": "2018-04-02T19:59:39", "url": "https://files.pythonhosted.org/packages/27/10/5ef43c516e80c9b2cb2322855160ed30a7dc2d209e7a80cf18ff8c6dc13b/django-class-auth-views-1.0.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "014d15e4e9e13bfbf2c3563804b043f2", "sha256": "1d5d424cbda92a25c823523655c0815cb0dc3df764fe332d997109384dbb78ff" }, "downloads": -1, "filename": "django-class-auth-views-1.0.1.tar.gz", "has_sig": false, "md5_digest": "014d15e4e9e13bfbf2c3563804b043f2", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5818, "upload_time": "2018-06-08T10:55:06", "url": "https://files.pythonhosted.org/packages/c7/61/0d8c9ee837778390abb64ee7bc53aa088f763cbd3ea143a1e5044c876861/django-class-auth-views-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "f4cffafdcda4018c3477122d75768944", "sha256": "8e023124bd9de83fae60a4747edad7e52377f0132716f79b6a6ee782297b1d88" }, "downloads": -1, "filename": "django-class-auth-views-1.0.2.tar.gz", "has_sig": false, "md5_digest": "f4cffafdcda4018c3477122d75768944", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5818, "upload_time": "2018-06-08T11:07:35", "url": "https://files.pythonhosted.org/packages/69/23/6dec6b971df59dbed46b82d0eba3b54cc806edc3cf9b46fc221bc2027086/django-class-auth-views-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "f4cffafdcda4018c3477122d75768944", "sha256": "8e023124bd9de83fae60a4747edad7e52377f0132716f79b6a6ee782297b1d88" }, "downloads": -1, "filename": "django-class-auth-views-1.0.2.tar.gz", "has_sig": false, "md5_digest": "f4cffafdcda4018c3477122d75768944", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5818, "upload_time": "2018-06-08T11:07:35", "url": "https://files.pythonhosted.org/packages/69/23/6dec6b971df59dbed46b82d0eba3b54cc806edc3cf9b46fc221bc2027086/django-class-auth-views-1.0.2.tar.gz" } ] }