コード例 #1
0
ファイル: registrations.py プロジェクト: vcelis/cs253-wiki
  def post(self):
    """Handles the post requests for the login page

    The user will get logged out when authentication succeeds and the request
    will get processed.
    """
    self.restrictedArea(True)
    fields = [ 'username', 'password' ]
    raw = { field: self.request.get(field) for field in fields }
    error, params = utils.validateLogin(**raw)
    
    if error:
      self.render(settings.TEMPLATE_FILENAME['login'], **params)
    else:
      u = User.login(raw['username'], raw['password'])
      if u:
        self.setCookie('uid', utils.genCookie(u.key.integer_id()))
        self.redirect('/')
      else:
        params['error_login'] = '******'
        self.render(settings.TEMPLATE_FILENAME['login'], **params)
コード例 #2
0
ファイル: registrations.py プロジェクト: vcelis/cs253-wiki
  def post(self):
    """Handles the post requests for the signup page

    The user will get logged out when authentication succeeds and the request
    will get processed.
    """
    self.restrictedArea(True)
    fields = [ 'username', 'password', 'verify', 'email' ]
    raw = { field: self.request.get(field) for field in fields }
    error, params = utils.validateSignup(**raw)
    
    if error:
      self.render(settings.TEMPLATE_FILENAME['signup'], **params)
    else:
      if User.getName(raw['username']):
        params['error_username'] = '******'
        self.render(settings.TEMPLATE_FILENAME['signup'], **params)
      else:
        u = User.register(raw['username'], raw['password'], raw['email'])
        u.put()
        self.setCookie('uid', utils.genCookie(u.key.integer_id()))
        self.redirect('/')