Esempio n. 1
0
 def testConnAndRefreshIfNecessary(self):
     # refresh every 15 seconds
     try:
         now = utilities.now_millis()
         if (self._test_process_time + 15000) < now:
             row = self._selectRowWithoutCheck("select count(1)")
             self._test_process_time = now
     except:
         self.log.info("Refreshing connection to db")
         self.connect()
Esempio n. 2
0
 def testConnAndRefreshIfNecessary(self):
     # refresh every 15 seconds
     try:
         now = utilities.now_millis()
         if (self._test_process_time + 15000) < now:
             row = self._selectRowWithoutCheck("select count(1)")
             self._test_process_time = now
     except:
         self.log.info("Refreshing connection to db")
         self.connect()
Esempio n. 3
0
    def login(self, access_token, user_id, email, name):

        # update user record with email and name
        sql = """
        INSERT INTO
            users (user_id, name, email, date_created)
        VALUES
            (%s, %s, %s, %s)
        ON DUPLICATE KEY UPDATE name=%s, email=%s"""
        params = [user_id, name, email, now_millis(), name, email]
        self.db.execute(sql, params)

        # update project access rows with the user_id
        sql = """
        UPDATE
            project_access
        SET
            user_id = %s
        WHERE
            email = %s"""
        params = [user_id, email]

        # save the access token
        expiry_time = now_millis() + self.token_ttl_millis
        sql = """

        INSERT INTO
            `logins` (access_token, user_id, expiry_time) 
        VALUES
            (%s, %s, %s)
        ON DUPLICATE KEY UPDATE access_token=%s;
        """
        params = [access_token, user_id, expiry_time, access_token]
        self.db.execute(sql, params)

        return {
            "access_token": access_token,
            "expiry_time": expiry_time
        }
Esempio n. 4
0
    def login(self, access_token, user_id, email, name):

        # update user record with email and name
        sql = """
        INSERT INTO
            users (user_id, name, email, date_created)
        VALUES
            (%s, %s, %s, %s)
        ON DUPLICATE KEY UPDATE name=%s, email=%s"""
        params = [user_id, name, email, now_millis(), name, email]
        self.db.execute(sql, params)

        # update project access rows with the user_id
        sql = """
        UPDATE
            project_access
        SET
            user_id = %s
        WHERE
            email = %s"""
        params = [user_id, email]

        # save the access token
        expiry_time = now_millis() + self.token_ttl_millis
        sql = """

        INSERT INTO
            `logins` (access_token, user_id, expiry_time) 
        VALUES
            (%s, %s, %s)
        ON DUPLICATE KEY UPDATE access_token=%s;
        """
        params = [access_token, user_id, expiry_time, access_token]
        self.db.execute(sql, params)

        return {"access_token": access_token, "expiry_time": expiry_time}