github
0 of 18 new or added lines in 4 files covered. (0.0%)
3922 existing lines in 105 files now uncovered.0 of 4086 relevant lines covered (0.0%)
0.0 hits per line
1 |
# frozen_string_literal: true
|
|
2 |
|
|
UNCOV
3
|
module Admin |
× |
4 |
# Requires that all actions of an including controller are performed
|
|
5 |
# by an user with admin flag set to true.
|
|
UNCOV
6
|
module Authenticatable |
× |
7 |
|
|
UNCOV
8
|
extend ActiveSupport::Concern |
× |
9 |
|
|
UNCOV
10
|
included do
|
× |
UNCOV
11
|
before_action :require_admin
|
× |
UNCOV
12
|
end
|
× |
13 |
|
|
UNCOV
14
|
private |
× |
15 |
|
|
UNCOV
16
|
def require_admin |
× |
UNCOV
17
|
if current_user
|
× |
UNCOV
18
|
render_forbidden unless current_user.admin?
|
× |
UNCOV
19
|
else
|
× |
UNCOV
20
|
render_unauthorized |
× |
UNCOV
21
|
end
|
× |
UNCOV
22
|
end
|
× |
23 |
|
|
UNCOV
24
|
def fetch_current_user |
× |
UNCOV
25
|
Auth::Jwt.new(request).fetch_user |
× |
UNCOV
26
|
end
|
× |
27 |
|
|
UNCOV
28
|
def render_forbidden |
× |
UNCOV
29
|
render json: { errors: 'Forbidden' }, status: :forbidden |
× |
UNCOV
30
|
end
|
× |
31 |
|
|
UNCOV
32
|
end
|
× |
UNCOV
33
|
end
|
× |