-##parameters=b_start=0, member_id='', given_name='', name='', member_email='', password='', confirm='', send_password='', add='', ajax=''
+##parameters=member_id='', given_name='', name='', member_email='', email_as_login='', password='', confirm='', add='', ajax=''
##
from Products.CMFCore.utils import getToolByName
from Products.CMFDefault.permissions import ManageUsers
form = context.REQUEST.form
-if add and \
- context.validatePassword(**form) and \
- context.members_add_control(**form) and \
- context.setRedirect(atool, 'user/join', b_start=b_start, ajax=ajax):
- return
+
+if add :
+ if validate_email :
+ password = confirm = rtool.generatePassword()
+ else :
+ ok = context.validatePassword(**form)
+ try :
+ if email_as_login :
+ member_id = member_email
+ rtool.addMember(id=member_id, password=password,
+ properties={'username': member_id,
+ 'given_name' : given_name,
+ 'name' : name,
+ 'email': member_email})
+ context.setStatus(True, _('Success!'))
+ except ValueError, errmsg:
+ context.setStatus(False, errmsg)
+
+
+
+# if add and \
+# context.validatePassword(**form) and \
+# context.members_add_control(**form) and \
+# context.setRedirect(atool, 'user/join', b_start=b_start, ajax=ajax):
+# return
options = {}
options['name'] = name
options['member_email'] = member_email
options['password'] = is_newmember and context.REQUEST.get('password', '') or ''
-options['send_password'] = send_password
options['portal_url'] = portal_url
options['isAnon'] = is_anon
-options['isAnonOrUserManager'] = is_anon or is_usermanager
options['isNewMember'] = is_newmember
-options['isOrdinaryMember'] = not (is_anon or is_newmember or is_usermanager)
options['validate_email'] = validate_email
options['isAnonRegistration'] = rtool.getMode() == MODE_ANONYMOUS
options['isReviewedRegistration'] = rtool.getMode() == MODE_REVIEWED
tal:define="form options/form">
<h1 i18n:translate="">Become a member</h1>
<div class="Desktop">
- <p tal:condition="options/isOrdinaryMember" i18n:translate="">
+ <p tal:condition="not:options/isAnon" i18n:translate="">
You are already authenticated. You may use the
<a tal:attributes="href string:$portal_url/personalize_form"
i18n:name="personalize_form"
</p>
</div>
- <div tal:condition="options/isAnonOrUserManager">
+ <div tal:condition="options/isAnon">
<form method="post" tal:attributes="action form/action">
<table>
<tr>
placeholder="Email address" i18n:attributes="placeholder"
tal:attributes="value options/member_email|nothing"/>
<label>
- <input type="checkbox" name="email_as_login"
+ <input type="checkbox" name="email_as_login" value="email_as_login"
tal:attributes="checked python:options.get('email_as_login', True)"/>
<span tal:omit-tag="" i18n:translate="">use as login</span>
</label>