diff options
Diffstat (limited to 'forum_modules/localauth')
-rwxr-xr-x | forum_modules/localauth/__init__.py | 0 | ||||
-rwxr-xr-x | forum_modules/localauth/authentication.py | 18 | ||||
-rwxr-xr-x | forum_modules/localauth/forms.py | 77 | ||||
-rwxr-xr-x | forum_modules/localauth/templates/loginform.html | 31 | ||||
-rwxr-xr-x | forum_modules/localauth/urls.py | 8 | ||||
-rwxr-xr-x | forum_modules/localauth/views.py | 31 |
6 files changed, 0 insertions, 165 deletions
diff --git a/forum_modules/localauth/__init__.py b/forum_modules/localauth/__init__.py deleted file mode 100755 index e69de29b..00000000 --- a/forum_modules/localauth/__init__.py +++ /dev/null diff --git a/forum_modules/localauth/authentication.py b/forum_modules/localauth/authentication.py deleted file mode 100755 index 770ea08f..00000000 --- a/forum_modules/localauth/authentication.py +++ /dev/null @@ -1,18 +0,0 @@ -from forum.authentication.base import AuthenticationConsumer, ConsumerTemplateContext, InvalidAuthentication -from forms import ClassicLoginForm - -class LocalAuthConsumer(AuthenticationConsumer): - def process_authentication_request(self, request): - form_auth = ClassicLoginForm(request.POST) - - if form_auth.is_valid(): - return form_auth.get_user() - else: - raise InvalidAuthentication(" ".join(form_auth.errors.values()[0])) - -class LocalAuthContext(ConsumerTemplateContext): - mode = 'STACK_ITEM' - weight = 1000 - human_name = 'Local authentication' - stack_item_template = 'modules/localauth/loginform.html' - show_to_logged_in_user = False
\ No newline at end of file diff --git a/forum_modules/localauth/forms.py b/forum_modules/localauth/forms.py deleted file mode 100755 index 8afa2b05..00000000 --- a/forum_modules/localauth/forms.py +++ /dev/null @@ -1,77 +0,0 @@ -from forum.utils.forms import NextUrlField, UserNameField, UserEmailField, SetPasswordForm -from forum.models import EmailFeedSetting, Question -from django.contrib.contenttypes.models import ContentType -from django.utils.translation import ugettext as _ -from django.contrib.auth import authenticate -from django import forms -import logging - -class ClassicRegisterForm(SetPasswordForm): - """ legacy registration form """ - - next = NextUrlField() - username = UserNameField() - email = UserEmailField() - #fields password1 and password2 are inherited - #recaptcha = ReCaptchaField() - -class ClassicLoginForm(forms.Form): - """ legacy account signin form """ - next = NextUrlField() - username = UserNameField(required=False,skip_clean=True) - password = forms.CharField(max_length=128, - widget=forms.widgets.PasswordInput(attrs={'class':'required login'}), - required=False) - - def __init__(self, data=None, files=None, auto_id='id_%s', - prefix=None, initial=None): - super(ClassicLoginForm, self).__init__(data, files, auto_id, - prefix, initial) - self.user_cache = None - - def _clean_nonempty_field(self,field): - value = None - if field in self.cleaned_data: - value = str(self.cleaned_data[field]).strip() - if value == '': - value = None - self.cleaned_data[field] = value - return value - - def clean_username(self): - return self._clean_nonempty_field('username') - - def clean_password(self): - return self._clean_nonempty_field('password') - - def clean(self): - error_list = [] - username = self.cleaned_data['username'] - password = self.cleaned_data['password'] - - self.user_cache = None - if username and password: - self.user_cache = authenticate(username=username, password=password) - - if self.user_cache is None: - del self.cleaned_data['username'] - del self.cleaned_data['password'] - error_list.insert(0,(_("Please enter valid username and password " - "(both are case-sensitive)."))) - elif self.user_cache.is_active == False: - error_list.append(_("This account is inactive.")) - if len(error_list) > 0: - error_list.insert(0,_('Login failed.')) - elif password == None and username == None: - error_list.append(_('Please enter username and password')) - elif password == None: - error_list.append(_('Please enter your password')) - elif username == None: - error_list.append(_('Please enter user name')) - if len(error_list) > 0: - self._errors['__all__'] = forms.util.ErrorList(error_list) - return self.cleaned_data - - def get_user(self): - """ get authenticated user """ - return self.user_cache
\ No newline at end of file diff --git a/forum_modules/localauth/templates/loginform.html b/forum_modules/localauth/templates/loginform.html deleted file mode 100755 index b1784fb6..00000000 --- a/forum_modules/localauth/templates/loginform.html +++ /dev/null @@ -1,31 +0,0 @@ -{% load i18n %}
-
-<fieldset id='local_login_fs'>
- <p><span class='big strong'>Enter your local user name and password</span><br/><span class='grey'>(or select your external provider above)</span></p>
- <table>
- <tr>
- <td>
- <label for="id_username">Login name</label>
- </td>
- <td>
- <input id="id_username" type="text" class="required login" name="username" maxlength="30" />
- </td>
- </tr>
- <tr>
- <td>
- <label for="id_password">Password</label>
- </td>
- <td>
- <input id="id_password" type="password" class="required login" name="password" maxlength="128" />
- </td>
- </tr>
- <tr>
- <td>
- <input id="blogin" name="blogin" type="submit" value="Login" />
- </td>
- <td>
- <a href="{% url auth_local_register %}">Create account</a><span> | </span><a href="{% url auth_request_tempsignin %}">Forgot your password?</a>
- </td>
- </tr>
- </table>
-</fieldset>
\ No newline at end of file diff --git a/forum_modules/localauth/urls.py b/forum_modules/localauth/urls.py deleted file mode 100755 index aeebc40a..00000000 --- a/forum_modules/localauth/urls.py +++ /dev/null @@ -1,8 +0,0 @@ -from django.conf.urls.defaults import * -from django.views.generic.simple import direct_to_template -from django.utils.translation import ugettext as _ -import views as app - -urlpatterns = patterns('', - url(r'^%s%s%s$' % (_('account/'), _('local/'), _('register/')), app.register, name='auth_local_register'), -)
\ No newline at end of file diff --git a/forum_modules/localauth/views.py b/forum_modules/localauth/views.py deleted file mode 100755 index db71e902..00000000 --- a/forum_modules/localauth/views.py +++ /dev/null @@ -1,31 +0,0 @@ -from django.contrib.auth.models import User -from django.shortcuts import render_to_response -from django.template import RequestContext -from django.utils.translation import ugettext as _ - -from forms import ClassicRegisterForm -from forum.authentication.forms import SimpleEmailSubscribeForm -from forum.views.auth import login_and_forward, send_validation_email - -def register(request): - if request.method == 'POST': - form = ClassicRegisterForm(request.POST) - email_feeds_form = SimpleEmailSubscribeForm(request.POST) - - if form.is_valid() and email_feeds_form.is_valid(): - username = form.cleaned_data['username'] - password = form.cleaned_data['password1'] - email = form.cleaned_data['email'] - - user_ = User.objects.create_user( username,email,password ) - send_validation_email(user_) - email_feeds_form.save(user_) - return login_and_forward(request, user_, None, _("A validation email has been sent to your email address. ")) - else: - form = ClassicRegisterForm(initial={'next':'/'}) - email_feeds_form = SimpleEmailSubscribeForm() - - return render_to_response('auth/signup.html', { - 'form': form, - 'email_feeds_form': email_feeds_form - }, context_instance=RequestContext(request))
\ No newline at end of file |