OCA\Richdocuments\Controller\SessionController::joinAsGuest PHP Method

joinAsGuest() public method

public joinAsGuest ( $token, $name )
    public function joinAsGuest($token, $name)
    {
        $uid = substr($name, 0, 16);
        try {
            $file = File::getByShareToken($token);
            if ($file->isPasswordProtected() && !$file->checkPassword('')) {
                throw new \Exception('Not authorized');
            }
            $response = array_merge(Db\Session::start($uid, $file), ['status' => 'success']);
        } catch (\Exception $e) {
            $this->logger->warning('Starting a session failed. Reason: ' . $e->getMessage(), ['app' => $this->appName]);
            $response = ['status' => 'error'];
        }
        return $response;
    }