示例#1
0
def signup():
    '''
  Register a new user.
  '''
    user = None
    pass_verified = None
    next = request.args.get('next', None)
    if request.method == 'POST':
        try:
            user = User()
            user.fill(**request.form.to_dict())
            pass_verified = request.form.get('verify') == request.form.get(
                'password')  # NOQA
            if user.valid() and user.unique and pass_verified:
                user.put()
                sec.token = {'usr': user.username, 'uid': user.uid}
                return redirect(next or url_for('root'))
        except Exception as ex:
            print('bad user')
            print(ex)
            return abort(500)
    return render_template('signup.html',
                           page=None,
                           user=user,
                           form_action=url_for('signup', next=next),
                           next=next,
                           pass_verified=pass_verified)
示例#2
0
def signup():
  user = None
  pass_verified = None
  if request.method == 'POST':
    try:
      user = User()
      user.fill(**request.form.to_dict())
      pass_verified = request.form.get('verify') == request.form.get('password')
      if user.valid() and user.unique and pass_verified:
        user.put()
        sec.token = {'username': user.username}
        return redirect(url_for('auth.welcome'))
    except Exception as ex:
      print('bad user')
      print(ex)
  try:
    return render_template('signup.html', auth=user, pass_verified=pass_verified)
  except TemplateNotFound:
    abort(404)