CheckMiddleware

Extends \OCP\AppFramework\Middleware

Checks that we have a valid token linked to a valid resource and that the user is authorised to access it

package

OCA\Gallery\Middleware

Methods

__construct

__construct( $appName, \OCP\IRequest $request, \OCP\IURLGenerator $urlGenerator, \OCP\ILogger $logger) 

Arguments

$appName

$request

\OCP\IRequest

$urlGenerator

\OCP\IURLGenerator

$logger

\OCP\ILogger

If a CheckException is being caught, clients who sent an ajax requests get a JSON error response while the others are redirected to an error page

afterException( $controller,  $methodName, \Exception $exception) 
inheritDoc

Arguments

$controller

$methodName

$exception

\Exception

Decides which type of response to send

computeResponse(string $message, integer $code) : \OCP\AppFramework\Http\JSONResponse|\OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\JSONResponse|\OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse

Redirects the client to an error page

redirectToErrorPage(string $message, integer $code) : \OCP\AppFramework\Http\RedirectResponse

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\RedirectResponse

Shows an authentication form

sendHtml401() : \OCP\AppFramework\Http\TemplateResponse

Response

\OCP\AppFramework\Http\TemplateResponse

Redirects the client to an error page or shows an authentication form

sendHtmlResponse(string $message, integer $code) : \OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\RedirectResponse|\OCP\AppFramework\Http\TemplateResponse

Returns a JSON response to the client

sendJsonResponse(string $message, integer $code) : \OCP\AppFramework\Http\JSONResponse

Arguments

$message

string

$code

integer

Response

\OCP\AppFramework\Http\JSONResponse

Properties

appName

appName : string
var

Type(s)

string

request

request : \OCP\IRequest
var

Type(s)

\OCP\IRequest

urlGenerator

urlGenerator : \OCP\IURLGenerator
var

Type(s)

\OCP\IURLGenerator

logger

logger : \OCP\ILogger
var

Type(s)

\OCP\ILogger