コード例 #1
0
  def _on_learned_invite(self, result):
    """Called when the sql query to retrieve the invite hexkey and email out of the database finishes"""
    #fail if we couldnt find an invite
    if not result:
      self._reply(RESPONSE_CODES["BAD_EMAIL"])
      return
      
    #unpack the database response
    self.hexKey, self.email = result[0]

    #everything checks out, time to actually insert the user
    self.saltedPassword = DBUtil.format_auth(self.username, self.password)
    sql = "INSERT INTO accounts (username, balance, email, time, password) VALUES (%s, %s, %s, %s, %s) RETURNING username"
    inj = (self.username, STARTING_BALANCE, self.email, self.curTime, cyborg.Binary(self.saltedPassword))
    creationDeferred = self.db.Pool.conn_pool.runQuery(sql, inj)
    creationDeferred.addCallback(self._on_account_creation_succeeded)
    creationDeferred.addErrback(self._on_account_creation_failed)
コード例 #2
0
    def _on_learned_invite(self, result):
        """Called when the sql query to retrieve the invite hexkey and email out of the database finishes"""
        #fail if we couldnt find an invite
        if not result:
            self._reply(RESPONSE_CODES["BAD_EMAIL"])
            return

        #unpack the database response
        self.hexKey, self.email = result[0]

        #everything checks out, time to actually insert the user
        self.saltedPassword = DBUtil.format_auth(self.username, self.password)
        sql = "INSERT INTO accounts (username, balance, email, time, password) VALUES (%s, %s, %s, %s, %s) RETURNING username"
        inj = (self.username, STARTING_BALANCE, self.email, self.curTime,
               cyborg.Binary(self.saltedPassword))
        creationDeferred = self.db.Pool.conn_pool.runQuery(sql, inj)
        creationDeferred.addCallback(self._on_account_creation_succeeded)
        creationDeferred.addErrback(self._on_account_creation_failed)