decidim-verifications 0.31.8 → 0.32.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +7 -13
- data/app/commands/decidim/verifications/confirm_user_authorization.rb +28 -31
- data/app/commands/decidim/verifications/csv_census/confirm_census_authorization.rb +5 -14
- data/app/commands/decidim/verifications/perform_authorization_step.rb +1 -3
- data/app/commands/decidim/verifications/revoke_all_authorizations.rb +14 -1
- data/app/commands/decidim/verifications/revoke_by_condition_authorizations.rb +68 -0
- data/app/controllers/concerns/decidim/verifications/renewable.rb +1 -0
- data/app/controllers/decidim/verifications/admin/verifications_controller.rb +1 -1
- data/app/controllers/decidim/verifications/application_controller.rb +2 -5
- data/app/controllers/decidim/verifications/authorizations_controller.rb +6 -17
- data/app/controllers/decidim/verifications/csv_census/admin/census_controller.rb +2 -10
- data/app/controllers/decidim/verifications/csv_census/admin/census_records_controller.rb +2 -10
- data/app/controllers/decidim/verifications/csv_census/authorizations_controller.rb +1 -6
- data/app/controllers/decidim/verifications/id_documents/admin/config_controller.rb +1 -1
- data/app/controllers/decidim/verifications/id_documents/admin/confirmations_controller.rb +3 -9
- data/app/controllers/decidim/verifications/id_documents/admin/offline_confirmations_controller.rb +1 -1
- data/app/controllers/decidim/verifications/id_documents/admin/rejections_controller.rb +1 -2
- data/app/controllers/decidim/verifications/id_documents/authorizations_controller.rb +2 -4
- data/app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb +2 -3
- data/app/controllers/decidim/verifications/postal_letter/authorizations_controller.rb +3 -8
- data/app/controllers/decidim/verifications/sms/authorizations_controller.rb +3 -13
- data/app/forms/decidim/verifications/csv_census/admin/census_data_form.rb +1 -0
- data/app/forms/decidim/verifications/id_documents/admin/config_form.rb +1 -0
- data/app/views/decidim/verifications/csv_census/admin/census/index.html.erb +2 -2
- data/app/views/decidim/verifications/csv_census/admin/census/instructions.html.erb +4 -3
- data/app/views/decidim/verifications/id_documents/admin/confirmations/new.html.erb +3 -3
- data/app/views/decidim/verifications/id_documents/admin/offline_confirmations/new.html.erb +2 -2
- data/app/views/decidim/verifications/id_documents/admin/pending_authorizations/index.html.erb +1 -1
- data/app/views/decidim/verifications/id_documents/authorizations/_form.html.erb +1 -3
- data/app/views/decidim/verifications/postal_letter/admin/pending_authorizations/index.html.erb +1 -1
- data/app/views/dummy_authorization/_form.html.erb +3 -3
- data/config/locales/ar.yml +8 -9
- data/config/locales/bg.yml +22 -22
- data/config/locales/ca-IT.yml +32 -38
- data/config/locales/ca.yml +32 -38
- data/config/locales/cs.yml +26 -26
- data/config/locales/de.yml +29 -37
- data/config/locales/el.yml +8 -9
- data/config/locales/en.yml +7 -12
- data/config/locales/es-MX.yml +32 -38
- data/config/locales/es-PY.yml +32 -38
- data/config/locales/es.yml +32 -38
- data/config/locales/eu.yml +60 -66
- data/config/locales/fi-plain.yml +32 -33
- data/config/locales/fi.yml +32 -38
- data/config/locales/fr-CA.yml +26 -52
- data/config/locales/fr.yml +26 -52
- data/config/locales/ga-IE.yml +0 -1
- data/config/locales/gl.yml +14 -201
- data/config/locales/hu.yml +11 -11
- data/config/locales/id-ID.yml +8 -9
- data/config/locales/is-IS.yml +9 -10
- data/config/locales/it.yml +9 -9
- data/config/locales/ja.yml +32 -38
- data/config/locales/lb.yml +0 -1
- data/config/locales/lt.yml +11 -11
- data/config/locales/lv.yml +8 -9
- data/config/locales/nl.yml +9 -9
- data/config/locales/no.yml +9 -9
- data/config/locales/pl.yml +22 -22
- data/config/locales/pt-BR.yml +28 -28
- data/config/locales/pt.yml +9 -9
- data/config/locales/ro-RO.yml +9 -9
- data/config/locales/ru.yml +8 -9
- data/config/locales/sk.yml +8 -208
- data/config/locales/sl.yml +0 -1
- data/config/locales/sv.yml +26 -38
- data/config/locales/tr-TR.yml +9 -10
- data/config/locales/uk.yml +8 -9
- data/config/locales/zh-CN.yml +8 -9
- data/config/locales/zh-TW.yml +11 -11
- data/decidim-verifications.gemspec +7 -8
- data/lib/decidim/verifications/adapter.rb +12 -1
- data/lib/decidim/verifications/engine.rb +11 -3
- data/lib/decidim/verifications/version.rb +1 -1
- data/lib/decidim/verifications.rb +8 -3
- metadata +11 -17
- data/app/commands/decidim/verifications/revoke_authorizations_by_condition.rb +0 -46
- data/app/controllers/concerns/decidim/verifications/admin/pending_authorization_loader.rb +0 -23
- data/app/jobs/decidim/verifications/revoke_all_authorizations_job.rb +0 -30
- data/app/jobs/decidim/verifications/revoke_authorizations_by_condition_job.rb +0 -44
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 18eeb490e000d6bdf84f6a1745e60fd21d005e88c2a9bb16a8e660b6b090ea2b
|
|
4
|
+
data.tar.gz: 82511430b2884829f35dae429c9bc611bf14c88f16f4328fa9d3a87e87dc560e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '096de425a399c348ec3f0964d53a484310686280b3ed1d28de458566585b7f65ea0b9bf306eb9706cbd37062c498661bcdfe0080f1a0875c0304d7c946cfeb34'
|
|
7
|
+
data.tar.gz: 5a7f737b1c79c194e1c859c5ef83c5fb07bf8fc2fae183ec3994fc60b27474f36e7590c8f0b188f707d1c7e29f1a0fb8e5cea4d9f765ea7ebdaf31de7cc22426
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# decidim-verifications
|
|
2
2
|
|
|
3
3
|
Decidim offers several methods for allowing participants to get authorization to
|
|
4
4
|
perform certain privileged actions. This module implements several of those methods
|
|
@@ -23,6 +23,10 @@ There are several use cases for this, such as
|
|
|
23
23
|
Right now Decidim supports only a few of these cases, but we have an internal
|
|
24
24
|
API where you can program your own kind of authorizations.
|
|
25
25
|
|
|
26
|
+
## Usage
|
|
27
|
+
|
|
28
|
+
This is a module oriented for developers, as a building block to be used by other modules.
|
|
29
|
+
|
|
26
30
|
## Introduction
|
|
27
31
|
|
|
28
32
|
Each decidim instance is in full control of its authorizations, and can customize:
|
|
@@ -151,7 +155,7 @@ In order to setup Decidim with SMS verification you need to:
|
|
|
151
155
|
Keep in mind that Decidim will not store a free text version of the mobile phone, only a hashed
|
|
152
156
|
version so we can avoid duplicates and guarantee the users' privacy.
|
|
153
157
|
|
|
154
|
-
You can find an example [
|
|
158
|
+
You can find an example in the [example SMS gateway implementation][example SMS gateway].
|
|
155
159
|
|
|
156
160
|
## Authorization options
|
|
157
161
|
|
|
@@ -243,17 +247,7 @@ authorization.
|
|
|
243
247
|
|
|
244
248
|
## Installation
|
|
245
249
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
```ruby
|
|
249
|
-
gem 'decidim-verifications'
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
And then execute:
|
|
253
|
-
|
|
254
|
-
```bash
|
|
255
|
-
bundle
|
|
256
|
-
```
|
|
250
|
+
This is on the default Decidim installation so you should not change anything to use this feature.
|
|
257
251
|
|
|
258
252
|
## Contributing
|
|
259
253
|
|
|
@@ -4,41 +4,36 @@ module Decidim
|
|
|
4
4
|
module Verifications
|
|
5
5
|
# A command to confirm a previous partial authorization.
|
|
6
6
|
class ConfirmUserAuthorization < Decidim::Command
|
|
7
|
+
# Number of failed confirmation attempts before throttling.
|
|
8
|
+
MAX_FAILED_ATTEMPTS = 2
|
|
9
|
+
|
|
7
10
|
# Public: Initializes the command.
|
|
8
11
|
#
|
|
9
12
|
# authorization - An Authorization to be confirmed.
|
|
10
13
|
# form - A form object with the verification data to confirm it.
|
|
11
|
-
def initialize(authorization, form)
|
|
14
|
+
def initialize(authorization, form, session)
|
|
12
15
|
@authorization = authorization
|
|
13
16
|
@form = form
|
|
17
|
+
@session = session
|
|
14
18
|
end
|
|
15
19
|
|
|
16
20
|
# Executes the command. Broadcasts these events:
|
|
17
21
|
#
|
|
18
22
|
# - :ok when everything is valid.
|
|
19
23
|
# - :invalid if the handler was not valid and we could not proceed.
|
|
20
|
-
# - :locked if too many failed attempts and the authorization is locked.
|
|
21
|
-
# - :expired if the verification code has expired.
|
|
22
24
|
#
|
|
23
25
|
# Returns nothing.
|
|
24
26
|
def call
|
|
25
27
|
return already_confirmed! if authorization.granted?
|
|
26
28
|
|
|
27
|
-
|
|
28
|
-
authorization.lock!
|
|
29
|
-
authorization.clear_expired_lock!
|
|
30
|
-
|
|
31
|
-
return locked! if authorization.locked_for_confirmation?
|
|
32
|
-
|
|
33
|
-
return invalid! unless form.valid?
|
|
29
|
+
return invalid! unless form.valid?
|
|
34
30
|
|
|
35
|
-
|
|
31
|
+
throttle! if too_many_failed_attempts?
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
end
|
|
33
|
+
if confirmation_successful?
|
|
34
|
+
valid!
|
|
35
|
+
else
|
|
36
|
+
invalid!
|
|
42
37
|
end
|
|
43
38
|
rescue StandardError => e
|
|
44
39
|
invalid!(e.message)
|
|
@@ -56,39 +51,41 @@ module Decidim
|
|
|
56
51
|
|
|
57
52
|
def valid!
|
|
58
53
|
authorization.grant!
|
|
59
|
-
|
|
54
|
+
reset_failed_attempts!
|
|
60
55
|
broadcast(:ok)
|
|
61
56
|
end
|
|
62
57
|
|
|
63
58
|
def invalid!(message = nil)
|
|
64
|
-
|
|
59
|
+
record_failed_attempt!
|
|
65
60
|
broadcast(:invalid, message)
|
|
66
61
|
end
|
|
67
62
|
|
|
68
63
|
def already_confirmed!
|
|
69
|
-
|
|
64
|
+
reset_failed_attempts!
|
|
70
65
|
broadcast(:already_confirmed)
|
|
71
66
|
end
|
|
72
67
|
|
|
73
|
-
def
|
|
74
|
-
|
|
68
|
+
def too_many_failed_attempts?
|
|
69
|
+
failed_attempts > MAX_FAILED_ATTEMPTS
|
|
75
70
|
end
|
|
76
71
|
|
|
77
|
-
def
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
def failed_attempts
|
|
73
|
+
session[:failed_attempts] ||= 0
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def reset_failed_attempts!
|
|
77
|
+
session[:failed_attempts] = 0
|
|
78
|
+
end
|
|
80
79
|
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
def record_failed_attempt!
|
|
81
|
+
session[:failed_attempts] = failed_attempts + 1
|
|
83
82
|
end
|
|
84
83
|
|
|
85
|
-
def
|
|
86
|
-
|
|
87
|
-
authorization.reset_failed_attempts!
|
|
88
|
-
broadcast(:expired)
|
|
84
|
+
def throttle!
|
|
85
|
+
sleep rand * failed_attempts
|
|
89
86
|
end
|
|
90
87
|
|
|
91
|
-
attr_reader :authorization, :form
|
|
88
|
+
attr_reader :authorization, :form, :session
|
|
92
89
|
end
|
|
93
90
|
end
|
|
94
91
|
end
|
|
@@ -7,20 +7,11 @@ module Decidim
|
|
|
7
7
|
def call
|
|
8
8
|
return broadcast(:invalid) unless form.valid?
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
authorization.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if confirmation_successful?
|
|
17
|
-
authorization.grant!
|
|
18
|
-
authorization.reset_failed_attempts!
|
|
19
|
-
broadcast(:ok)
|
|
20
|
-
else
|
|
21
|
-
authorization.record_failed_attempt!
|
|
22
|
-
broadcast(:invalid)
|
|
23
|
-
end
|
|
10
|
+
if confirmation_successful?
|
|
11
|
+
authorization.grant!
|
|
12
|
+
broadcast(:ok)
|
|
13
|
+
else
|
|
14
|
+
broadcast(:invalid)
|
|
24
15
|
end
|
|
25
16
|
end
|
|
26
17
|
end
|
|
@@ -34,9 +34,7 @@ module Decidim
|
|
|
34
34
|
unique_id: handler.unique_id,
|
|
35
35
|
metadata: handler.metadata,
|
|
36
36
|
verification_metadata: handler.verification_metadata,
|
|
37
|
-
verification_attachment: handler.verification_attachment
|
|
38
|
-
failed_attempts: 0,
|
|
39
|
-
locked_at: nil
|
|
37
|
+
verification_attachment: handler.verification_attachment
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
authorization.save!
|
|
@@ -22,7 +22,20 @@ module Decidim
|
|
|
22
22
|
def call
|
|
23
23
|
return broadcast(:invalid) unless @organization
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
auths = Decidim::Verifications::Authorizations.new(
|
|
26
|
+
organization:,
|
|
27
|
+
granted: true
|
|
28
|
+
).query
|
|
29
|
+
|
|
30
|
+
auths.find_each do |auth|
|
|
31
|
+
Decidim.traceability.perform_action!(
|
|
32
|
+
:destroy,
|
|
33
|
+
auth,
|
|
34
|
+
current_user
|
|
35
|
+
) do
|
|
36
|
+
auth.destroy
|
|
37
|
+
end
|
|
38
|
+
end
|
|
26
39
|
|
|
27
40
|
broadcast(:ok)
|
|
28
41
|
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Decidim
|
|
4
|
+
module Verifications
|
|
5
|
+
# A command to revoke authorizations with filter
|
|
6
|
+
class RevokeByConditionAuthorizations < Decidim::Command
|
|
7
|
+
delegate :current_user, to: :form
|
|
8
|
+
# Public: Initializes the command.
|
|
9
|
+
#
|
|
10
|
+
# organization - Organization object.
|
|
11
|
+
# current_user - The current user.
|
|
12
|
+
# form - A form object with the verification data to confirm it.
|
|
13
|
+
def initialize(organization, form)
|
|
14
|
+
@organization = organization
|
|
15
|
+
@form = form
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
# Executes the command. Broadcasts these events:
|
|
19
|
+
#
|
|
20
|
+
# - :ok when everything is valid.
|
|
21
|
+
# - :invalid if the handler was not valid and we could not proceed.
|
|
22
|
+
#
|
|
23
|
+
# Returns nothing.
|
|
24
|
+
def call
|
|
25
|
+
return broadcast(:invalid) unless @organization
|
|
26
|
+
return broadcast(:invalid) unless @form.valid?
|
|
27
|
+
|
|
28
|
+
# Check before date
|
|
29
|
+
if @form.before_date.present?
|
|
30
|
+
authorizations_to_revoke = if @form.impersonated_only?
|
|
31
|
+
Decidim::Verifications::AuthorizationsBeforeDate.new(
|
|
32
|
+
organization:,
|
|
33
|
+
date: @form.before_date,
|
|
34
|
+
granted: true,
|
|
35
|
+
impersonated_only: @form.impersonated_only
|
|
36
|
+
)
|
|
37
|
+
else
|
|
38
|
+
Decidim::Verifications::AuthorizationsBeforeDate.new(
|
|
39
|
+
organization:,
|
|
40
|
+
date: @form.before_date,
|
|
41
|
+
granted: true
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
auths = authorizations_to_revoke.query
|
|
46
|
+
auths.find_each do |auth|
|
|
47
|
+
Decidim.traceability.perform_action!(
|
|
48
|
+
:destroy,
|
|
49
|
+
auth,
|
|
50
|
+
current_user
|
|
51
|
+
) do
|
|
52
|
+
auth.destroy
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
broadcast(:ok)
|
|
57
|
+
|
|
58
|
+
else
|
|
59
|
+
broadcast(:invalid)
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
private
|
|
64
|
+
|
|
65
|
+
attr_reader :organization, :form
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
|
@@ -9,7 +9,7 @@ module Decidim
|
|
|
9
9
|
return unless params.has_key?(:revocations_before_date)
|
|
10
10
|
|
|
11
11
|
form = RevocationsBeforeDateForm.from_params(params[:revocations_before_date])
|
|
12
|
-
|
|
12
|
+
RevokeByConditionAuthorizations.call(current_organization, form) do
|
|
13
13
|
on(:ok) do
|
|
14
14
|
flash[:notice] = t("authorization_revocation.destroy_ok", scope: "decidim.admin.menu")
|
|
15
15
|
redirect_to decidim_admin.authorization_workflows_url
|
|
@@ -10,8 +10,6 @@ module Decidim
|
|
|
10
10
|
|
|
11
11
|
before_action :confirmed_user, only: [:new, :create, :renew]
|
|
12
12
|
|
|
13
|
-
protected
|
|
14
|
-
|
|
15
13
|
def new
|
|
16
14
|
raise NotImplementedError
|
|
17
15
|
end
|
|
@@ -29,9 +27,8 @@ module Decidim
|
|
|
29
27
|
def confirmed_user
|
|
30
28
|
return true if !current_user || (current_user && current_user.verifiable?)
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
alert: t(
|
|
30
|
+
redirect_back_or_to(
|
|
31
|
+
root_path, alert: t(
|
|
35
32
|
"authorizations.create.unconfirmed",
|
|
36
33
|
scope: "decidim.verifications"
|
|
37
34
|
)
|
|
@@ -14,23 +14,18 @@ module Decidim
|
|
|
14
14
|
include Decidim::UserProfile
|
|
15
15
|
include Decidim::HtmlSafeFlash
|
|
16
16
|
include Decidim::Verifications::Renewable
|
|
17
|
+
|
|
17
18
|
helper Decidim::DecidimFormHelper
|
|
18
19
|
helper Decidim::AuthorizationFormHelper
|
|
19
20
|
helper Decidim::TranslationsHelper
|
|
20
21
|
|
|
21
22
|
layout "layouts/decidim/authorizations", except: [:index, :onboarding_pending]
|
|
22
23
|
|
|
23
|
-
def new
|
|
24
|
-
enforce_permission_to :read, :authorization
|
|
25
|
-
end
|
|
24
|
+
def new; end
|
|
26
25
|
|
|
27
|
-
def index
|
|
28
|
-
enforce_permission_to :read, :authorization
|
|
29
|
-
end
|
|
26
|
+
def index; end
|
|
30
27
|
|
|
31
28
|
def onboarding_pending
|
|
32
|
-
enforce_permission_to :read, :authorization
|
|
33
|
-
|
|
34
29
|
return redirect_back_or_to(authorizations_path) unless onboarding_manager.valid?
|
|
35
30
|
|
|
36
31
|
authorizations = action_authorized_to(onboarding_manager.action, **onboarding_manager.action_authorized_resources)
|
|
@@ -61,8 +56,6 @@ module Decidim
|
|
|
61
56
|
end
|
|
62
57
|
|
|
63
58
|
def create
|
|
64
|
-
enforce_permission_to(:create, :authorization, authorization:)
|
|
65
|
-
|
|
66
59
|
AuthorizeUser.call(handler, current_organization) do
|
|
67
60
|
on(:ok) do
|
|
68
61
|
flash[:notice] = t("authorizations.create.success", scope: "decidim.verifications")
|
|
@@ -94,22 +87,18 @@ module Decidim
|
|
|
94
87
|
|
|
95
88
|
on(:invalid) do
|
|
96
89
|
flash[:alert] = t("authorizations.create.error", scope: "decidim.verifications")
|
|
97
|
-
render action: :new, status: :
|
|
90
|
+
render action: :new, status: :unprocessable_content
|
|
98
91
|
end
|
|
99
92
|
end
|
|
100
93
|
end
|
|
101
94
|
|
|
102
95
|
def renew_onboarding_data
|
|
103
|
-
enforce_permission_to :read, :authorization
|
|
104
|
-
|
|
105
96
|
store_onboarding_cookie_data!(current_user)
|
|
106
97
|
|
|
107
98
|
redirect_to onboarding_pending_authorizations_path
|
|
108
99
|
end
|
|
109
100
|
|
|
110
101
|
def clear_onboarding_data
|
|
111
|
-
enforce_permission_to :read, :authorization
|
|
112
|
-
|
|
113
102
|
clear_onboarding_data!(current_user)
|
|
114
103
|
end
|
|
115
104
|
|
|
@@ -163,7 +152,7 @@ module Decidim
|
|
|
163
152
|
authorizations = action_authorized_to(onboarding_manager.action, **onboarding_manager.action_authorized_resources)
|
|
164
153
|
return unless authorizations.ephemeral?
|
|
165
154
|
|
|
166
|
-
form = Decidim::EphemeralUserForm.new(organization: current_organization
|
|
155
|
+
form = Decidim::EphemeralUserForm.new(organization: current_organization)
|
|
167
156
|
CreateEphemeralUser.call(form) do
|
|
168
157
|
on(:ok) do |ephemeral_user|
|
|
169
158
|
sign_in(ephemeral_user)
|
|
@@ -198,7 +187,7 @@ module Decidim
|
|
|
198
187
|
private
|
|
199
188
|
|
|
200
189
|
def authorization
|
|
201
|
-
@authorization ||= Decidim::Authorization.
|
|
190
|
+
@authorization ||= Decidim::Authorization.find_by(
|
|
202
191
|
user: current_user,
|
|
203
192
|
name: handler_name
|
|
204
193
|
)
|
|
@@ -18,13 +18,9 @@ module Decidim
|
|
|
18
18
|
|
|
19
19
|
helper_method :csv_census_data, :last_login
|
|
20
20
|
|
|
21
|
-
def index
|
|
22
|
-
enforce_permission_to :index, :authorization
|
|
23
|
-
end
|
|
21
|
+
def index; end
|
|
24
22
|
|
|
25
23
|
def destroy
|
|
26
|
-
enforce_permission_to :destroy, :authorization
|
|
27
|
-
|
|
28
24
|
Decidim::Commands::DestroyResource.call(census_data, current_user) do
|
|
29
25
|
on(:ok) do
|
|
30
26
|
flash[:notice] = I18n.t("census.destroy.success", scope: "decidim.verifications.csv_census.admin")
|
|
@@ -34,15 +30,12 @@ module Decidim
|
|
|
34
30
|
end
|
|
35
31
|
|
|
36
32
|
def new_import
|
|
37
|
-
enforce_permission_to :create, :authorization
|
|
38
|
-
|
|
39
33
|
@form = form(CensusDataForm).from_params(params)
|
|
40
34
|
@status = Status.new(current_organization)
|
|
41
35
|
end
|
|
42
36
|
|
|
43
37
|
def create_import
|
|
44
38
|
enforce_permission_to :create, :authorization
|
|
45
|
-
|
|
46
39
|
@form = form(CensusDataForm).from_params(params)
|
|
47
40
|
@status = Status.new(current_organization)
|
|
48
41
|
|
|
@@ -83,7 +76,6 @@ module Decidim
|
|
|
83
76
|
|
|
84
77
|
def show_instructions
|
|
85
78
|
enforce_permission_to :index, :authorization
|
|
86
|
-
|
|
87
79
|
render :instructions
|
|
88
80
|
end
|
|
89
81
|
|
|
@@ -96,7 +88,7 @@ module Decidim
|
|
|
96
88
|
|
|
97
89
|
return { icon: nil, text: t(".no_user"), last_sign_in: nil } unless user
|
|
98
90
|
|
|
99
|
-
authorized = Decidim::Authorization.where(name: "csv_census", user:)
|
|
91
|
+
authorized = Decidim::Authorization.where(name: "csv_census", user:)
|
|
100
92
|
.where.not(granted_at: nil)
|
|
101
93
|
.exists?
|
|
102
94
|
|
|
@@ -10,14 +10,10 @@ module Decidim
|
|
|
10
10
|
helper_method :csv_census_data
|
|
11
11
|
|
|
12
12
|
def new_record
|
|
13
|
-
enforce_permission_to :create, :authorization
|
|
14
|
-
|
|
15
13
|
@form = form(Admin::CensusForm).instance
|
|
16
14
|
end
|
|
17
15
|
|
|
18
16
|
def create_record
|
|
19
|
-
enforce_permission_to :create, :authorization
|
|
20
|
-
|
|
21
17
|
@form = form(Admin::CensusForm).from_params(params)
|
|
22
18
|
Admin::CreateCensusRecord.call(@form) do
|
|
23
19
|
on(:ok) do
|
|
@@ -26,20 +22,16 @@ module Decidim
|
|
|
26
22
|
end
|
|
27
23
|
|
|
28
24
|
on(:invalid) do
|
|
29
|
-
render :new_record, status: :
|
|
25
|
+
render :new_record, status: :unprocessable_content
|
|
30
26
|
end
|
|
31
27
|
end
|
|
32
28
|
end
|
|
33
29
|
|
|
34
30
|
def edit_record
|
|
35
|
-
enforce_permission_to :update, :authorization
|
|
36
|
-
|
|
37
31
|
@form = form(Admin::CensusForm).from_model(census_data)
|
|
38
32
|
end
|
|
39
33
|
|
|
40
34
|
def update_record
|
|
41
|
-
enforce_permission_to :update, :authorization
|
|
42
|
-
|
|
43
35
|
@form = form(Admin::CensusForm).from_params(params)
|
|
44
36
|
|
|
45
37
|
Admin::UpdateCensusRecord.call(@form, census_data) do
|
|
@@ -50,7 +42,7 @@ module Decidim
|
|
|
50
42
|
|
|
51
43
|
on(:invalid) do
|
|
52
44
|
flash.now[:alert] = I18n.t("census_records.update_record.invalid", scope: "decidim.verifications.csv_census.admin")
|
|
53
|
-
render action: "edit_record", status: :
|
|
45
|
+
render action: "edit_record", status: :unprocessable_content
|
|
54
46
|
end
|
|
55
47
|
end
|
|
56
48
|
end
|
|
@@ -11,19 +11,14 @@ module Decidim
|
|
|
11
11
|
before_action :load_authorization
|
|
12
12
|
|
|
13
13
|
def new
|
|
14
|
-
enforce_permission_to :create, :authorization, authorization: @authorization
|
|
15
|
-
|
|
16
14
|
@form = CensusForm.from_params(user: current_user)
|
|
17
|
-
ConfirmCensusAuthorization.call(@authorization, @form) do
|
|
15
|
+
ConfirmCensusAuthorization.call(@authorization, @form, session) do
|
|
18
16
|
on(:ok) do
|
|
19
17
|
flash[:notice] = t("authorizations.new.success", scope: "decidim.verifications.csv_census")
|
|
20
18
|
end
|
|
21
19
|
on(:invalid) do
|
|
22
20
|
flash[:alert] = t("authorizations.new.error", scope: "decidim.verifications.csv_census")
|
|
23
21
|
end
|
|
24
|
-
on(:locked) do
|
|
25
|
-
flash[:alert] = t("authorizations.new.locked", scope: "decidim.verifications.csv_census")
|
|
26
|
-
end
|
|
27
22
|
redirect_to decidim_verifications.authorizations_path
|
|
28
23
|
end
|
|
29
24
|
end
|
|
@@ -33,7 +33,7 @@ module Decidim
|
|
|
33
33
|
|
|
34
34
|
on(:invalid) do
|
|
35
35
|
flash.now[:alert] = t("config.update.error", scope: "decidim.verifications.id_documents.admin")
|
|
36
|
-
render action: :edit, status: :
|
|
36
|
+
render action: :edit, status: :unprocessable_content
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -13,7 +13,6 @@ module Decidim
|
|
|
13
13
|
before_action :load_pending_authorization
|
|
14
14
|
|
|
15
15
|
include Decidim::Admin::WorkflowsBreadcrumb
|
|
16
|
-
include Decidim::Verifications::Admin::PendingAuthorizationLoader
|
|
17
16
|
|
|
18
17
|
add_breadcrumb_item_from_menu :workflows_menu
|
|
19
18
|
|
|
@@ -28,7 +27,7 @@ module Decidim
|
|
|
28
27
|
|
|
29
28
|
@form = InformationForm.from_params(params)
|
|
30
29
|
|
|
31
|
-
ConfirmUserAuthorization.call(@pending_authorization, @form) do
|
|
30
|
+
ConfirmUserAuthorization.call(@pending_authorization, @form, session) do
|
|
32
31
|
on(:ok) do
|
|
33
32
|
flash[:notice] = t("confirmations.create.success", scope: "decidim.verifications.id_documents.admin")
|
|
34
33
|
redirect_to pending_authorizations_path
|
|
@@ -36,12 +35,7 @@ module Decidim
|
|
|
36
35
|
|
|
37
36
|
on(:invalid) do
|
|
38
37
|
flash.now[:alert] = t("confirmations.create.error", scope: "decidim.verifications.id_documents.admin")
|
|
39
|
-
render action: :new, status: :
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
on(:locked) do
|
|
43
|
-
flash.now[:alert] = t("confirmations.create.locked", scope: "decidim.verifications.id_documents.admin")
|
|
44
|
-
render action: :new, status: :too_many_requests
|
|
38
|
+
render action: :new, status: :unprocessable_content
|
|
45
39
|
end
|
|
46
40
|
end
|
|
47
41
|
end
|
|
@@ -49,7 +43,7 @@ module Decidim
|
|
|
49
43
|
private
|
|
50
44
|
|
|
51
45
|
def load_pending_authorization
|
|
52
|
-
@pending_authorization =
|
|
46
|
+
@pending_authorization = Authorization.find(params[:pending_authorization_id])
|
|
53
47
|
end
|
|
54
48
|
end
|
|
55
49
|
end
|
data/app/controllers/decidim/verifications/id_documents/admin/offline_confirmations_controller.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Decidim
|
|
|
33
33
|
|
|
34
34
|
on(:invalid) do
|
|
35
35
|
flash.now[:alert] = t("offline_confirmations.create.error", scope: "decidim.verifications.id_documents.admin")
|
|
36
|
-
render action: :new, status: :
|
|
36
|
+
render action: :new, status: :unprocessable_content
|
|
37
37
|
end
|
|
38
38
|
end
|
|
39
39
|
end
|
|
@@ -13,7 +13,6 @@ module Decidim
|
|
|
13
13
|
before_action :load_pending_authorization
|
|
14
14
|
|
|
15
15
|
include Decidim::Admin::WorkflowsBreadcrumb
|
|
16
|
-
include Decidim::Verifications::Admin::PendingAuthorizationLoader
|
|
17
16
|
|
|
18
17
|
add_breadcrumb_item_from_menu :workflows_menu
|
|
19
18
|
|
|
@@ -33,7 +32,7 @@ module Decidim
|
|
|
33
32
|
private
|
|
34
33
|
|
|
35
34
|
def load_pending_authorization
|
|
36
|
-
@pending_authorization =
|
|
35
|
+
@pending_authorization = Authorization.find(params[:pending_authorization_id])
|
|
37
36
|
end
|
|
38
37
|
end
|
|
39
38
|
end
|
|
@@ -14,8 +14,6 @@ module Decidim
|
|
|
14
14
|
before_action :load_authorization
|
|
15
15
|
|
|
16
16
|
def choose
|
|
17
|
-
enforce_permission_to :create, :authorization, authorization: @authorization
|
|
18
|
-
|
|
19
17
|
url_params = { redirect_url: }.compact
|
|
20
18
|
|
|
21
19
|
return redirect_to(action: :new, **url_params.merge(using: verification_type)) if available_methods.count == 1
|
|
@@ -44,7 +42,7 @@ module Decidim
|
|
|
44
42
|
|
|
45
43
|
on(:invalid) do
|
|
46
44
|
flash.now[:alert] = t("authorizations.create.error", scope: "decidim.verifications.id_documents")
|
|
47
|
-
render action: :new, status: :
|
|
45
|
+
render action: :new, status: :unprocessable_content
|
|
48
46
|
end
|
|
49
47
|
end
|
|
50
48
|
end
|
|
@@ -74,7 +72,7 @@ module Decidim
|
|
|
74
72
|
|
|
75
73
|
on(:invalid) do
|
|
76
74
|
flash.now[:alert] = t("authorizations.update.error", scope: "decidim.verifications.id_documents")
|
|
77
|
-
render action: :edit, status: :
|
|
75
|
+
render action: :edit, status: :unprocessable_content
|
|
78
76
|
end
|
|
79
77
|
end
|
|
80
78
|
end
|
|
@@ -13,7 +13,6 @@ module Decidim
|
|
|
13
13
|
before_action :load_pending_authorization
|
|
14
14
|
|
|
15
15
|
include Decidim::Admin::WorkflowsBreadcrumb
|
|
16
|
-
include Decidim::Verifications::Admin::PendingAuthorizationLoader
|
|
17
16
|
|
|
18
17
|
add_breadcrumb_item_from_menu :workflows_menu
|
|
19
18
|
|
|
@@ -29,7 +28,7 @@ module Decidim
|
|
|
29
28
|
end
|
|
30
29
|
|
|
31
30
|
on(:invalid) do
|
|
32
|
-
render json: { error: I18n.t("postages.create.error", scope: "decidim.verifications.postal_letter.admin") }, status: :
|
|
31
|
+
render json: { error: I18n.t("postages.create.error", scope: "decidim.verifications.postal_letter.admin") }, status: :unprocessable_content
|
|
33
32
|
end
|
|
34
33
|
end
|
|
35
34
|
end
|
|
@@ -37,7 +36,7 @@ module Decidim
|
|
|
37
36
|
private
|
|
38
37
|
|
|
39
38
|
def load_pending_authorization
|
|
40
|
-
@pending_authorization =
|
|
39
|
+
@pending_authorization = Authorization.find(params[:pending_authorization_id])
|
|
41
40
|
end
|
|
42
41
|
end
|
|
43
42
|
end
|