Phpauth\Auth::getRequest PHP Method

getRequest() public method

Returns request data if key is valid
public getRequest ( string $key, string $type ) : array
$key string
$type string
return array $return
    public function getRequest($key, $type)
    {
        $return['error'] = true;
        $query = $this->dbh->prepare("SELECT id, uid, expire FROM {$this->config->table_requests} WHERE rkey = ? AND type = ?");
        $query->execute(array($key, $type));
        if (!($row = $query->fetch(\PDO::FETCH_ASSOC))) {
            $this->addAttempt();
            $return['message'] = $this->lang[$type . "key_incorrect"];
            return $return;
        }
        $expiredate = strtotime($row['expire']);
        $currentdate = strtotime(date("Y-m-d H:i:s"));
        if ($currentdate > $expiredate) {
            $this->addAttempt();
            $this->deleteRequest($row['id']);
            $return['message'] = $this->lang[$type . "key_expired"];
            return $return;
        }
        $return['error'] = false;
        $return['id'] = $row['id'];
        $return['uid'] = $row['uid'];
        return $return;
    }