Skip to content

Commit 4e79fcd

Browse files
author
Chris Talib
committed
[fix] adding a 401 page and a new method in service controller to controll access to curators only
1 parent 86f8549 commit 4e79fcd

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

app/controllers/services_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
class ServicesController < ApplicationController
22
before_action :authenticate_user!, except: [:index, :show]
3+
before_action :set_curator, except: [:index, :show]
34
before_action :set_service, only: [:show, :edit, :update, :destroy]
45

56
def index
@@ -74,4 +75,9 @@ def service_params
7475
params.require(:service).permit(:name, :url, :query)
7576
end
7677

78+
def set_curator
79+
unless current_user.curator?
80+
render :file => "public/401.html", :status => :unauthorized
81+
end
82+
end
7783
end

public/401.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<body style="background-color: #FdFdFd;color: #F89300;text-align: center;">
4+
<!-- This file lives in public/401.html -->
5+
<h1>Uh-Oh!</h1>
6+
<h2>You are not authorized to do this!</h2>
7+
<div class="back-home" style="margin-top: 50px;margin-bottom: 10px;">
8+
<a href="/" class="btn" style="margin-top: 30px;background-color: #49A347;border-radius: 50px;color: white;font-weight: bold;padding: 10px 20px;">
9+
Back Home</a>
10+
</div>
11+
<p>
12+
<a href="https://github.com/tosdr/phoenix/issues/" style="margin: 0;text-decoration: none;color: grey;">Open an issue on Github</a>
13+
</p>
14+
<p>
15+
<a href="mailto:[email protected]" style="margin: 0;text-decoration: none;color: grey;">Contact us</a>
16+
</p>
17+
</body>
18+
</html>

0 commit comments

Comments
 (0)