Created
April 16, 2012 11:44
-
-
Save graingert/2398002 to your computer and use it in GitHub Desktop.
django-browserid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django_browserid.views import Verify | |
| from django_browserid.auth import BrowserIDBackend | |
| class EmailNotWhitelistedError(Exception): | |
| pass | |
| def create_user(email): | |
| if email.rsplit('@', 1)[0] in ("ecs.soton.ac.uk","soton.ac.uk"): | |
| print email | |
| return BrowserIDBackend().create_user(email) | |
| else: | |
| raise EmailNotWhitelistedError | |
| class EmailCheckingVerify(Verify): | |
| def form_valid(self, form): | |
| print "foo" | |
| try: | |
| print "trying" | |
| return super(EmailCheckingVerify, self).form_valid(form) | |
| except EmailNotWhitelistedError: | |
| print "invalid email" | |
| return self.login_failure() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| BROWSERID_CREATE_USER = "application.views.create_user" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from django.conf.urls.defaults import patterns, include, url | |
| from application.views import EmailCheckingVerify | |
| urlpatterns = patterns('', | |
| url(r'^browserid/verify/$', EmailCheckingVerify.as_view()), | |
| url(r'', include('django_browserid.urls')), | |
| ) |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
WTFPL ^