1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-01 23:20:51 +00:00

Modify registration flow, add new flag into settings.py

* when ACTIVATE_AFTER_REGISTRATION set to True, user will be activated after registration, and no email sending;
* when ACTIVATE_AFTER_REGISTRATION set to False, and REGISTRAION_SEND_EMAIL set to True, user will be activated by email;
* when ACTIVATE_AFTER_REGISTRATION set to False, and REGISTRAION_SEND_EMAIL set to Flase, user will be activated by admin.
This commit is contained in:
xiez
2012-04-21 13:58:55 +08:00
parent 00f9575c74
commit 325d39a288
3 changed files with 28 additions and 12 deletions

View File

@@ -209,13 +209,21 @@ class RegistrationBackend(object):
else:
site = RequestSite(request)
new_user = RegistrationProfile.objects.create_active_user(username, email,
password, site,
send_email=settings.REGISTRATION_SEND_MAIL)
# login the user
new_user.backend='auth.backends.ModelBackend'
login(request, new_user)
if settings.ACTIVATE_AFTER_REGISTRATION == True:
# since user will be activated after registration,
# so we will not use email sending, just create acitvated user
new_user = RegistrationProfile.objects.create_active_user(username, email,
password, site,
send_email=False)
# login the user
new_user.backend='auth.backends.ModelBackend'
login(request, new_user)
else:
# create inactive user, user can be activated by admin, or through activated email
new_user = RegistrationProfile.objects.create_inactive_user(username, email,
password, site,
send_email=settings.REGISTRATION_SEND_MAIL)
userid = kwargs['userid']
if userid:

View File

@@ -7,6 +7,13 @@ from registration.views import register
from seahub.base.accounts import RegistrationForm
reg_dict = { 'backend': 'seahub.base.accounts.RegistrationBackend',
'form_class': RegistrationForm,
}
if settings.ACTIVATE_AFTER_REGISTRATION == True:
reg_dict['success_url'] = '/'
urlpatterns = patterns('',
url(r'^activate/complete/$',
direct_to_template,
@@ -22,10 +29,7 @@ urlpatterns = patterns('',
name='registration_activate'),
url(r'^register/$',
register,
{ 'backend': 'seahub.base.accounts.RegistrationBackend',
'form_class': RegistrationForm,
'success_url': '/',
},
reg_dict,
name='registration_register'),
url(r'^register/complete/$',
direct_to_template,

View File

@@ -113,8 +113,12 @@ AUTHENTICATION_BACKENDS = (
ACCOUNT_ACTIVATION_DAYS = 7
# this value should be false, since user will be activated after registration
# since 0.9.2
# Set to True when user will be activaed after registration,
# and no email sending
ACTIVATE_AFTER_REGISTRATION = True
# In order to use email sending,
# ACTIVATE_AFTER_REGISTRATION MUST set to False
REGISTRATION_SEND_MAIL = False
# seafile httpserver address and port