Unverified Commit 91f8b5cc authored by robertperez-upc's avatar robertperez-upc Committed by GitHub
Browse files

Apply app CSS to access_denied template (#1690)

* Apply app CSS to access_denied template

* access_denied at /machine/view if not logged, instead of redirect to /login
parent a3f0105c
......@@ -783,7 +783,7 @@ get '/machine/view/(:id).(:type)' => sub {
my $id = $c->stash('id');
my $type = $c->stash('type');
return $c->redirect_to('/login') if !_logged_in($c);
# return $c->redirect_to('/login') if !_logged_in($c);
my ($domain) = _search_requested_machine($c);
return access_denied($c) if !$domain;
......@@ -2692,10 +2692,8 @@ sub access_denied_json($c, $msg='Access denied') {
}
sub access_denied {
my $c = shift;
my $msg = shift;
if (!$msg) {
$msg = 'Access denied to '.$c->req->url->to_abs->path;
$msg .= ' for user '.$USER->name if $USER && !$USER->is_temporary;
......@@ -2704,7 +2702,21 @@ sub access_denied {
if (defined $c->stash('type') && $c->stash('type') eq 'json') {
return $c->render(json => { error => $msg }, status => 403);
}
return $c->render(text => $msg, status => 403);
my @css_snippets = ["\t.intro {\n\t\tbackground:"
." url($CONFIG_FRONT->{login_bg_file})"
." no-repeat bottom center scroll;\n\t}"];
return $c->render(
template => ($CONFIG_FRONT->{access_denied} or 'main/access_denied')
,css => ['/css/main.css']
,csssnippets => @css_snippets
,js => ['/js/main.js?v='.$RAVADA->version]
,navbar_custom => 1
,error => $msg
,can_login => ((! $USER) || ($USER->is_temporary))
,guide => $CONFIG_FRONT->{guide}
,status => 403
);
}
sub _access_denied { return access_denied(@_) }
......
<!DOCTYPE html>
<html>
%= include 'bootstrap/header'
<body role="document">
%= include 'bootstrap/navigation'
<header id="page-top" class="intro">
<div class="intro-body">
<div class="container" ng-controller="">
<h2 class="form-signin-heading">ERROR</h2>
<p><%= $error %></p>
% if ($can_login) {
<form class="form-singin" method="get" action="/">
<button id="submit" class="btn btn-success btn-lg btn-block" type="submit"><%=l 'Login' %></button>
</form>
% }
</div>
</div>
</header>
%= include 'bootstrap/scripts'
%= include $footer
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment