Skullabs/kikaha

Customize permission denied page

roneigebert opened this issue · 2 comments

In my permission denied page, I need to get the previous page URL, because through Javascript it is not possible.

I thing the easyer way (maybe not the best) to do this is changing the method AuthenticationRunner#redirectToPermissionDeniedPage, from:

void redirectToPermissionDeniedPage() {
	exchange.setStatusCode( 303 );
	exchange.getResponseHeaders().put( Headers.LOCATION, permissionDeniedPage );
}

To:

void redirectToPermissionDeniedPage(HttpServerExchange exchange) {
	val currentPageUrl = currentEscapedPage(exchange);
	exchange.setStatusCode( 303 );
	val permissionDeniedPage  = permissionDeniedPage.replace("{current-page}", currentPageUrl);
	exchange.getResponseHeaders().put( Headers.LOCATION, permissionDeniedPage );
}

and than I can use in my conf file:

server:
  auth:
    endpoints:
      permission-denied-page: "/forbidden?previousPage={current-page}"

@miere, can you help me with this?

miere commented