diff options
-rwxr-xr-x | index.py | 16 | ||||
-rw-r--r-- | templates/create.html | 2 |
2 files changed, 12 insertions, 6 deletions
@@ -81,11 +81,7 @@ class SubdapSite(object): # details.append([k, value]) ## x += '<tr><td>%s</td><td><pre>%s</pre></td></tr>\n' % (k, "<hr>".join(v)) - @expose('create.html') - def create(s): - return render(errors = {}, username = '') - @expose('create.html') - def docreate(s, username = None, password = None, password2 = None): + def params_validate(s, errors, username, password, password2): errors = {} if username == None or username == '': errors['username'] = 'please specify an user name' @@ -96,6 +92,16 @@ class SubdapSite(object): if password2 != password: errors['password2'] = 'passwords did not match' if len(errors) > 0: + return errors + return None + + @expose('create.html') + def create(s, username = None, password = None, password2 = None): + if cherrypy.request.method.upper() == 'GET': + return render(errors = {}, username = '') + + errors = s.params_validate(errors, username, password, password2) + if errors is not None: return render(errors = errors, username = username) accountservice.name_create(username, password) diff --git a/templates/create.html b/templates/create.html index fbf1323..eb2bdc1 100644 --- a/templates/create.html +++ b/templates/create.html @@ -9,7 +9,7 @@ <title>create</title> </head> <sub:bodyform> - <form action='docreate' method='POST'> + <form action='create' method='POST'> <div>uid: <input type='text' name='username' size="10" value="${username}"/></div> <b class="error" py:if="'username' in errors">${errors.username}</b> <div id="creatpw">password: <input type='password' name='password' size="10" value=""/></div> |