Skip to content

Commit

Permalink
changes around inactive users, settings key rename
Browse files Browse the repository at this point in the history
  • Loading branch information
farin committed Apr 1, 2011
1 parent 64f586e commit 8c4dbfe
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,13 @@ All settings are optional. Defaults are:
ENROLL_FORBID_USERNAME_DERIVED_PASSWORD = False

ENROLL_AUTH_BACKEND_LOGIN_ATTRIBUTES = [ username ] #(use enroll.backends.ModelBackend to have effect)
ENROLL_AUTH_BACKEND_INACTIVE_USER = True #is allowed login authentication by inactive user

ENROLL_ACCOUNT_VERIFICATION_REQUIRED = True
ENROLL_VERIFICATION_TOKEN_VALID_DAYS = 14 #unlimited if False
ENROLL_VERIFICATION_TOKEN_LENGTH = 12
ENROLL_SEND_VERIFICATION_EMAIL = True
ENROLL_LOGIN_AFTER_ACTIVATION = True
ENROLL_AUTO_LOGIN = True
ENROLL_AUTO_VERIFY = True

LOGIN_REDIRECT_URL #(also used by django auth)
LOGOUT_REDIRECT_URL
Expand Down
2 changes: 2 additions & 0 deletions enroll/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
class ModelBackend(DjangoModelBackend):
"""Extended authentication backend"""

supports_inactive_user = getattr(settings, 'ENROLL_AUTH_BACKEND_INACTIVE_USER', True )

#should contains only unique columns !!!
login_attributes = getattr(settings, 'ENROLL_AUTH_BACKEND_LOGIN_ATTRIBUTES', ['username'] )

Expand Down
8 changes: 4 additions & 4 deletions enroll/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class BaseSignUpForm(RequestAcceptingModelForm):

__metaclass__ = ExplicitValidationModelFormMetaclass

verification_required = getattr(settings , 'ENROLL_ACCOUNT_VERIFICATION_REQUIRED', True)
auto_verify_user = getattr(settings , 'ENROLL_AUTO_VERIFY', False)

field_validators = getattr(settings , 'ENROLL_FORM_VALIDATORS', {
'username': [ UniqueUsernameValidator ],
Expand All @@ -91,12 +91,12 @@ def save(self):

user = User.objects.create_user(username, email, password)

if self.verification_required:
if self.auto_verify_user:
token = None
else:
user.is_active = False
user.save()
token = self.create_verification_token(user)
else:
token = None

post_registration.send(sender=user.__class__, user=user, request=self.request, token=token)
return user
Expand Down
4 changes: 2 additions & 2 deletions enroll/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def send_failure_message(self):
class AutoLoginMixin(object):
"""Provides method to log user"""

login_on_success = getattr(settings, 'ENROLL_LOGIN_AFTER_ACTIVATION', True)
login_on_success = getattr(settings, 'ENROLL_AUTO_LOGIN', True)

def login_user(self, user):
anonymous_session_data = dict(self.request.session.items())
Expand Down Expand Up @@ -157,7 +157,7 @@ class VerifyPasswordResetView(AutoLoginMixin, SuccessMessageFormView):
template_name ='registration/password_reset_confirm.html'
form_class = PasswordResetStepTwoForm
success_url = '/'
login_on_success = getattr(settings, 'ENROLL_LOGIN_AFTER_ACTIVATION', True)
login_on_success = getattr(settings, 'ENROLL_AUTO_LOGIN', True)

def get_form_kwargs(self):
kwargs = dict(request=self.request, user=self.token.user)
Expand Down

0 comments on commit 8c4dbfe

Please sign in to comment.