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 |
|
|
3 |
# Requires that all write actions of an including controller are
|
|
4 |
# performed by a logged in user (and not only a guest with an access code).
|
|
UNCOV
5
|
module WriteAuthenticatable |
× |
6 |
|
|
UNCOV
7
|
extend ActiveSupport::Concern |
× |
8 |
|
|
UNCOV
9
|
included do
|
× |
UNCOV
10
|
before_action :require_user, only: [:create, :update, :destroy] |
× |
UNCOV
11
|
end
|
× |
12 |
|
|
UNCOV
13
|
private |
× |
14 |
|
|
UNCOV
15
|
def require_user |
× |
UNCOV
16
|
render_unauthorized unless current_user
|
× |
UNCOV
17
|
end
|
× |
18 |
|
|
UNCOV
19
|
def fetch_current_user |
× |
UNCOV
20
|
if %w[create update destroy].include?(action_name) |
× |
UNCOV
21
|
Auth::Jwt.new(request).fetch_user || |
× |
UNCOV
22
|
Auth::ApiToken.new(request).fetch_user |
× |
UNCOV
23
|
else
|
× |
UNCOV
24
|
super
|
× |
UNCOV
25
|
end
|
× |
UNCOV
26
|
end
|
× |
27 |
|
|
UNCOV
28
|
end
|
× |