summaryrefslogtreecommitdiffstats
path: root/forum/authentication
diff options
context:
space:
mode:
Diffstat (limited to 'forum/authentication')
-rwxr-xr-xforum/authentication/__init__.py27
-rwxr-xr-xforum/authentication/base.py44
-rwxr-xr-xforum/authentication/forms.py73
3 files changed, 0 insertions, 144 deletions
diff --git a/forum/authentication/__init__.py b/forum/authentication/__init__.py
deleted file mode 100755
index 75099303..00000000
--- a/forum/authentication/__init__.py
+++ /dev/null
@@ -1,27 +0,0 @@
-import re
-from forum.modules import get_modules_script_classes
-from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext
-
-class ConsumerAndContext():
- def __init__(self, id, consumer, context):
- self.id = id
- self.consumer = consumer()
-
- context.id = id #add extra field to context
- self.context = context
-
-consumers = dict([
- (re.sub('AuthConsumer$', '', name).lower(), cls) for name, cls
- in get_modules_script_classes('authentication', AuthenticationConsumer).items()
- if not re.search('AbstractAuthConsumer$', name)
- ])
-
-contexts = dict([
- (re.sub('AuthContext$', '', name).lower(), cls) for name, cls
- in get_modules_script_classes('authentication', ConsumerTemplateContext).items()
- ])
-
-AUTH_PROVIDERS = dict([
- (name, ConsumerAndContext(name, consumers[name], contexts[name])) for name in consumers.keys()
- if name in contexts
- ])
diff --git a/forum/authentication/base.py b/forum/authentication/base.py
deleted file mode 100755
index 99005866..00000000
--- a/forum/authentication/base.py
+++ /dev/null
@@ -1,44 +0,0 @@
-
-class AuthenticationConsumer(object):
-
- def prepare_authentication_request(self, request, redirect_to):
- raise NotImplementedError()
-
- def process_authentication_request(self, response):
- raise NotImplementedError()
-
- def get_user_data(self, key):
- raise NotImplementedError()
-
-
-class ConsumerTemplateContext(object):
- """
- Class that provides information about a certain authentication provider context in the signin page.
-
- class attributes:
-
- mode - one of BIGICON, SMALLICON, FORM
-
- human_name - the human readable name of the provider
-
- extra_js - some providers require us to load extra javascript on the signin page for them to work,
- this is the place to add those files in the form of a list
-
- extra_css - same as extra_js but for css files
- """
- mode = ''
- weight = 500
- human_name = ''
- extra_js = []
- extra_css = []
- show_to_logged_in_user = True
-
- @classmethod
- def readable_key(cls, key):
- return key.key
-
-class InvalidAuthentication(Exception):
- def __init__(self, message):
- self.message = message
-
- \ No newline at end of file
diff --git a/forum/authentication/forms.py b/forum/authentication/forms.py
deleted file mode 100755
index 24e76c08..00000000
--- a/forum/authentication/forms.py
+++ /dev/null
@@ -1,73 +0,0 @@
-from forum.utils.forms import NextUrlField, UserNameField, UserEmailField, SetPasswordForm
-from forum.models import EmailFeedSetting, Question, User
-from django.contrib.contenttypes.models import ContentType
-from django.utils.translation import ugettext as _
-from django.utils.safestring import mark_safe
-from django import forms
-from forum.forms import EditUserEmailFeedsForm
-import logging
-
-class SimpleRegistrationForm(forms.Form):
- next = NextUrlField()
- username = UserNameField()
- email = UserEmailField()
-
-class TemporaryLoginRequestForm(forms.Form):
- def __init__(self, data=None):
- super(TemporaryLoginRequestForm, self).__init__(data)
- self.user_cache = None
-
- email = forms.EmailField(
- required=True,
- label=_("Your account email"),
- error_messages={
- 'required': _("You cannot leave this field blank"),
- 'invalid': _('please enter a valid email address'),
- }
- )
-
- def clean_email(self):
- try:
- user = User.objects.get(email=self.cleaned_data['email'])
- except:
- raise forms.ValidationError(_("Sorry, but this email is not on our database."))
-
- self.user_cache = user
- return self.cleaned_data['email']
-
-
-class SimpleEmailSubscribeForm(forms.Form):
- SIMPLE_SUBSCRIBE_CHOICES = (
- ('y',_('okay, let\'s try!')),
- ('n',_('no community email please, thanks'))
- )
- subscribe = forms.ChoiceField(widget=forms.widgets.RadioSelect(), \
- error_messages={'required':_('please choose one of the options above')},
- choices=SIMPLE_SUBSCRIBE_CHOICES)
-
- def save(self,user=None):
- EFF = EditUserEmailFeedsForm
- if self.cleaned_data['subscribe'] == 'y':
- email_settings_form = EFF()
- logging.debug('%s wants to subscribe' % user.username)
- else:
- email_settings_form = EFF(initial=EFF.NO_EMAIL_INITIAL)
- email_settings_form.save(user,save_unbound=True)
-
-class ChangePasswordForm(SetPasswordForm):
- """ change password form """
- oldpw = forms.CharField(widget=forms.PasswordInput(attrs={'class':'required'}),
- label=mark_safe(_('Current password')))
-
- def __init__(self, data=None, user=None, *args, **kwargs):
- if user is None:
- raise TypeError("Keyword argument 'user' must be supplied")
- super(ChangePasswordForm, self).__init__(data, *args, **kwargs)
- self.user = user
-
- def clean_oldpw(self):
- """ test old password """
- if not self.user.check_password(self.cleaned_data['oldpw']):
- raise forms.ValidationError(_("Old password is incorrect. \
- Please enter the correct password."))
- return self.cleaned_data['oldpw']