public function validate($action = '', $token = null)
    {
        $app = Application::getFacadeApplication();
        if ($token == null) {
            $request = $app->make(Request::class);
            $token = $request->request->get(static::DEFAULT_TOKEN_NAME);
            if ($token === null) {
                $token = $request->query->get(static::DEFAULT_TOKEN_NAME);
            }
        }
        if (is_string($token)) {
            $parts = explode(':', $token);
            if ($parts[0] && isset($parts[1])) {
                $time = $parts[0];
                $hash = $parts[1];
                $compHash = $this->generate($action, $time);
                $now = time();

                if (substr($compHash, strpos($compHash, ':') + 1) == $hash) {
                    $diff = $now - $time;
                    //hash is only valid if $diff is less than VALID_HASH_TIME_RECORD
                    return $diff <= static::VALID_HASH_TIME_THRESHOLD;
                } else {
                    $logger = $app->make('log/factory')->createLogger(Channels::CHANNEL_SECURITY);
                    $u = new User();
                    $logger->debug(t('Validation token did not match'), [
                        'uID' => $u->getUserID(),
                        'action' => $action,
                        'time' => $time,
                    ]);
                }
            }
        }

        return false;
    }