decidim-verifications 0.11.2 → 0.12.0.pre

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.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +52 -3
  3. data/app/controllers/decidim/verifications/id_documents/admin/confirmations_controller.rb +2 -2
  4. data/app/controllers/decidim/verifications/id_documents/admin/pending_authorizations_controller.rb +1 -1
  5. data/app/controllers/decidim/verifications/id_documents/admin/rejections_controller.rb +1 -1
  6. data/app/controllers/decidim/verifications/id_documents/authorizations_controller.rb +4 -4
  7. data/app/controllers/decidim/verifications/postal_letter/admin/pending_authorizations_controller.rb +1 -1
  8. data/app/controllers/decidim/verifications/postal_letter/admin/postages_controller.rb +1 -1
  9. data/app/controllers/decidim/verifications/postal_letter/authorizations_controller.rb +4 -4
  10. data/config/locales/ca.yml +1 -0
  11. data/config/locales/en.yml +1 -0
  12. data/config/locales/es.yml +1 -0
  13. data/config/locales/eu.yml +1 -0
  14. data/config/locales/fi.yml +1 -0
  15. data/config/locales/fr.yml +1 -0
  16. data/config/locales/gl.yml +1 -0
  17. data/config/locales/it.yml +1 -0
  18. data/config/locales/nl.yml +1 -0
  19. data/config/locales/pl.yml +1 -0
  20. data/config/locales/pt-BR.yml +1 -0
  21. data/config/locales/pt.yml +1 -0
  22. data/config/locales/ru.yml +14 -0
  23. data/config/locales/sv.yml +1 -0
  24. data/config/locales/uk.yml +1 -0
  25. data/lib/decidim/verifications.rb +0 -1
  26. data/lib/decidim/verifications/version.rb +1 -1
  27. data/lib/decidim/verifications/workflow_manifest.rb +22 -0
  28. metadata +10 -12
  29. data/app/services/decidim/dummy_authorization_handler.rb +0 -62
  30. data/lib/decidim/verifications/dummy.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e08ca1a5127107a68f42f8e713783d202a78df58a9601b3062021b7c33f7a19
4
- data.tar.gz: dd2248607b155c81b29c981363affb11d3dbc4fe60d1818239d5d339116172a8
3
+ metadata.gz: 697e2cfabb509f91d19fa63bfb1ed743ca656db92435c0350f84193d55bc4b00
4
+ data.tar.gz: fa06aa8dfb5423b4fb44f24037e1ffe129bab58b3c24bed93083f49b429e5e42
5
5
  SHA512:
6
- metadata.gz: 6f1374e5f469df6adbb0d04b55205dcc92bcab11025f17fd362a3eda9e2e88b504cbc2f6570013f61e529a374bfdc1cbb7a26f9812e158f198069455bc600cfe
7
- data.tar.gz: 33d658f5cad09b84b9867be2a38f486a39d988edf0c30ba08be7d69b725b5458f0046d8ad672f1c3c2afa550152cfab33c5a2f121944b6bf5f9209373ee0e6c5
6
+ metadata.gz: 7c035b21d66752276f869f15bb4b799d26ab311e12e5d4dcb9e62b22c88852bb5b376f36c10e54447dad6bcf54320c164e008a224a79f70fc8f516d8975d0196
7
+ data.tar.gz: ab12caf3cda046c88458b66399f8218d7d98e71e11ecb42f57f942c5458819e3623e68d9d970c15220228f00296258f151e65fb4e622dff496d245f39b58271e
data/README.md CHANGED
@@ -5,6 +5,24 @@ perform certain privileged actions. This module implements several of those meth
5
5
  and also offers a way for installation to implement their custom verification
6
6
  methods.
7
7
 
8
+ There are several use cases for this, such as
9
+
10
+ * Sending a SMS code to users to verify that their have a valid cellphone
11
+
12
+ * Allowing users to upload a photo or scanned image of their identity document
13
+
14
+ * Sending users a code through postal code
15
+
16
+ * Allowing users to go to to a physical office and check their documentation
17
+
18
+ * Checking some information through other systems (as a Municipal Census on the
19
+ case of Municipalities, Cities or Towns)
20
+
21
+ * Having a list of valid users emails
22
+
23
+ Right now Decidim supports only a few of these cases, but we have an internal
24
+ API where you can program your own kind of authorizations.
25
+
8
26
  ## Introduction
9
27
 
10
28
  Each decidim instance is in full control of its authorizations, and can customize:
@@ -31,8 +49,12 @@ Decidim implements two type of authorization methods:
31
49
  a census API you will need a form with some fields that your users will use to
32
50
  authenticate against a census (for example, an ID and a Postal Code). You'll
33
51
  implement this with a form class. See the documentation for the [parent
34
- class][authorization handler base class] or have a look at a
35
- [live example][live authorization handler example] in decidim-barcelona.
52
+ class][authorization handler base class] or have a look at some live examples,
53
+ such as:
54
+
55
+ * [Decidim Barcelona].
56
+ * [Decidim Terrassa].
57
+ * [Decidim Sant Cugat].
36
58
 
37
59
  To register your handler, use
38
60
 
@@ -75,6 +97,30 @@ Decidim implements two type of authorization methods:
75
97
  * `edit_authorization_path`: This is the entry point to resume an existing
76
98
  authorization process.
77
99
 
100
+ ## Authorization options
101
+
102
+ Sometimes you want to scope authorizations only to users that meet certain
103
+ requirements. For example, you might only allow users registered at a certain
104
+ postal code to be verified and thus perform certain actions.
105
+
106
+ You can do this with authorization options. For example, in the case just
107
+ presented, you should define something like this in your authorization workflow:
108
+
109
+ ```ruby
110
+ Decidim::Verifications.register_workflow(:my_workflow) do |workflow|
111
+ workflow.form = "MyAuthorizationHandler"
112
+
113
+ workflow.options do |options|
114
+ options.attribute :postal_code, type: :string, required: false
115
+ end
116
+ end
117
+ ```
118
+
119
+ The format of the options you can define is the standard for a virtus attribute,
120
+ plus an additional `required` (true by default) option were you can choose
121
+ whether the option is compulsory when configuring the workflow as a permission
122
+ for an action or not.
123
+
78
124
  ## Custom action authorizers
79
125
 
80
126
  Custom action authorizers are an advanced component that can be used in both types of
@@ -150,4 +196,7 @@ See [Decidim](https://github.com/decidim/decidim).
150
196
  See [Decidim](https://github.com/decidim/decidim).
151
197
 
152
198
  [authorization handler base class]: https://github.com/decidim/decidim/blob/master/decidim-core/app/services/decidim/authorization_handler.rb
153
- [real authorization handler]: https://github.com/decidim/decidim-barcelona/blob/master/app/services/census_authorization_handler.rb
199
+
200
+ [Decidim Barcelona]: https://github.com/AjuntamentdeBarcelona/decidim-barcelona/blob/master/app/services/census_authorization_handler.rb
201
+ [Decidim Terrassa]: https://github.com/AjuntamentDeTerrassa/decidim-terrassa/blob/master/app/services/census_authorization_handler.rb
202
+ [Decidim Sant Cugat]: https://github.com/AjuntamentdeSantCugat/decidim-sant_cugat/blob/master/app/services/census_authorization_handler.rb
@@ -13,13 +13,13 @@ module Decidim
13
13
  before_action :load_pending_authorization
14
14
 
15
15
  def new
16
- authorize! :update, @pending_authorization
16
+ enforce_permission_to :update, :authorization, authorization: @pending_authorization
17
17
 
18
18
  @form = InformationForm.new
19
19
  end
20
20
 
21
21
  def create
22
- authorize! :update, @pending_authorization
22
+ enforce_permission_to :update, :authorization, authorization: @pending_authorization
23
23
 
24
24
  @form = InformationForm.from_params(params)
25
25
 
@@ -8,7 +8,7 @@ module Decidim
8
8
  layout "decidim/admin/users"
9
9
 
10
10
  def index
11
- authorize! :index, Authorization
11
+ enforce_permission_to :index, :authorization
12
12
 
13
13
  @pending_authorizations = pending_authorizations
14
14
  end
@@ -13,7 +13,7 @@ module Decidim
13
13
  before_action :load_pending_authorization
14
14
 
15
15
  def create
16
- authorize! :update, @pending_authorization
16
+ enforce_permission_to :update, :authorization, authorization: @pending_authorization
17
17
 
18
18
  @form = InformationRejectionForm.from_model(@pending_authorization)
19
19
 
@@ -12,13 +12,13 @@ module Decidim
12
12
  before_action :load_authorization
13
13
 
14
14
  def new
15
- authorize! :create, @authorization
15
+ enforce_permission_to :create, :authorization, authorization: @authorization
16
16
 
17
17
  @form = UploadForm.new
18
18
  end
19
19
 
20
20
  def create
21
- authorize! :create, @authorization
21
+ enforce_permission_to :create, :authorization, authorization: @authorization
22
22
 
23
23
  @form = UploadForm.from_params(params.merge(user: current_user))
24
24
 
@@ -36,13 +36,13 @@ module Decidim
36
36
  end
37
37
 
38
38
  def edit
39
- authorize! :update, @authorization
39
+ enforce_permission_to :update, :authorization, authorization: @authorization
40
40
 
41
41
  @form = UploadForm.from_model(@authorization)
42
42
  end
43
43
 
44
44
  def update
45
- authorize! :update, @authorization
45
+ enforce_permission_to :update, :authorization, authorization: @authorization
46
46
 
47
47
  @form = UploadForm.from_params(
48
48
  params.merge(
@@ -8,7 +8,7 @@ module Decidim
8
8
  layout "decidim/admin/users"
9
9
 
10
10
  def index
11
- authorize! :index, Authorization
11
+ enforce_permission_to :index, :authorization
12
12
 
13
13
  @pending_authorizations = AuthorizationPresenter.for_collection(
14
14
  pending_authorizations
@@ -13,7 +13,7 @@ module Decidim
13
13
  before_action :load_pending_authorization
14
14
 
15
15
  def create
16
- authorize! :update, @pending_authorization
16
+ enforce_permission_to :update, :authorization, authorization: @pending_authorization
17
17
 
18
18
  @form = PostageForm.from_model(@pending_authorization)
19
19
 
@@ -9,13 +9,13 @@ module Decidim
9
9
  before_action :load_authorization
10
10
 
11
11
  def new
12
- authorize! :create, @authorization
12
+ enforce_permission_to :create, :authorization, authorization: @authorization
13
13
 
14
14
  @form = AddressForm.new
15
15
  end
16
16
 
17
17
  def create
18
- authorize! :create, @authorization
18
+ enforce_permission_to :create, :authorization, authorization: @authorization
19
19
 
20
20
  @form = AddressForm.from_params(params.merge(user: current_user))
21
21
 
@@ -33,13 +33,13 @@ module Decidim
33
33
  end
34
34
 
35
35
  def edit
36
- authorize! :update, @authorization
36
+ enforce_permission_to :update, :authorization, authorization: @authorization
37
37
 
38
38
  @form = ConfirmationForm.from_params(params)
39
39
  end
40
40
 
41
41
  def update
42
- authorize! :update, @authorization
42
+ enforce_permission_to :update, :authorization, authorization: @authorization
43
43
 
44
44
  @form = ConfirmationForm.from_params(params)
45
45
 
@@ -51,6 +51,7 @@ ca:
51
51
  success: Has estat autoritzat amb èxit.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verifiqueu contra un altre exemple de controlador d'autorització
54
55
  dummy_authorization_handler: Verificar contra l'autorització d'exemple
55
56
  dummy_authorization_workflow: Verificar contra l'exemple de flux d'autorització
56
57
  id_documents: Verifica't carregant el teu document d'identitat
@@ -52,6 +52,7 @@ en:
52
52
  success: You've been successfully authorized.
53
53
  first_login:
54
54
  actions:
55
+ another_dummy_authorization_handler: Verify against another example of authorization handler
55
56
  dummy_authorization_handler: Verify against the example authorization handler
56
57
  dummy_authorization_workflow: Verify against the example authorization workflow
57
58
  id_documents: Get verified by uploading your identity document
@@ -51,6 +51,7 @@ es:
51
51
  success: Has sido autorizado/a correctamente.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verificar contra otro ejemplo de controlador de autorización
54
55
  dummy_authorization_handler: Verificar contra el gestor de autorización de ejemplo
55
56
  dummy_authorization_workflow: Verificar contra el flujo de autorización de ejemplo
56
57
  id_documents: Verifícate subiendo tu documento de identidad
@@ -51,6 +51,7 @@ eu:
51
51
  success: Ongi baimendu duzu.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Egiaztatu baimenen kudeatzailearen beste adibide baten aurka
54
55
  dummy_authorization_handler: Egiaztatu adibide-baimenaren kudeatzailearen aurka
55
56
  dummy_authorization_workflow: Egiaztatu baimenen laneko fluxuaren aurka
56
57
  id_documents: Egiaztatu zure identifikazio dokumentua kargatzen
@@ -51,6 +51,7 @@ fi:
51
51
  success: Tilisi on onnistuneesti vahvistettu.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Varmista toinen esimerkki valtuutuksen käsittelijästä
54
55
  dummy_authorization_handler: Vahvista tili esimerkkivaltuuttajan avulla
55
56
  dummy_authorization_workflow: Vahvista esimerkkivaltuutuksen työnkulkuprosessin kautta
56
57
  id_documents: Vahvista tilisi lataamalla henkilöllisyystodistuksesi
@@ -51,6 +51,7 @@ fr:
51
51
  success: Vous avez été autorisé avec succès.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Vérifier avec un autre exemple de gestionnaire d'autorisation
54
55
  dummy_authorization_handler: Vérifier en comparant avec l'exemple du gestionnaire d'autorisation
55
56
  dummy_authorization_workflow: Vérifiez par rapport à l'exemple de procédure d'autorisation
56
57
  id_documents: Soyez vérifié en téléchargeant votre document d'identité
@@ -51,6 +51,7 @@ gl:
51
51
  success: Autorizouse con éxito.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verifique contra outro exemplo de controlador de autorización
54
55
  dummy_authorization_handler: Verifique contra o controlador de autorización de exemplo
55
56
  dummy_authorization_workflow: Verifique contra o fluxo de traballo de autorización de exemplo
56
57
  id_documents: Verifique a carga do documento de identidade
@@ -51,6 +51,7 @@ it:
51
51
  success: Sei stato autorizzato con successo.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verificare contro un altro esempio di gestore di autorizzazioni
54
55
  dummy_authorization_handler: Verificare contro il gestore di autorizzazione di esempio
55
56
  dummy_authorization_workflow: Verificare il flusso di lavoro di autorizzazione di esempio
56
57
  id_documents: Ottieni la verifica caricando il tuo documento di identità
@@ -51,6 +51,7 @@ nl:
51
51
  success: U bent geautoriseerd.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Controleer tegen een ander voorbeeld van autorisatieaanduiding
54
55
  dummy_authorization_handler: Verifieer met het voorbeeld van de autorisatieaanduiding
55
56
  dummy_authorization_workflow: Controleer aan de hand van het machtigingsworkflow voorbeeld
56
57
  id_documents: Wordt geverifieerd door uw identiteitsdocument te uploaden
@@ -51,6 +51,7 @@ pl:
51
51
  success: Pomyślnie autoryzowano.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Sprawdź na przykładzie innego przykładu procedury obsługi autoryzacji
54
55
  dummy_authorization_handler: Sprawdź na przykładzie przykładowej procedury autoryzacji
55
56
  dummy_authorization_workflow: Sprawdź w przykładowym przepływie pracy autoryzacji
56
57
  id_documents: Uzyskaj weryfikację, przesyłając swój dokument tożsamości
@@ -51,6 +51,7 @@ pt-BR:
51
51
  success: Você foi autorizado com sucesso.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verificar contra outro exemplo de manipulador de autorização
54
55
  dummy_authorization_handler: Verifique contra o manipulador de autorização de exemplo
55
56
  dummy_authorization_workflow: Verifique o exemplo de fluxo de trabalho de autorização
56
57
  id_documents: Seja verificado ao fazer o upload do documento de identidade
@@ -51,6 +51,7 @@ pt:
51
51
  success: Você foi autorizado com sucesso.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verificar contra outro exemplo de manipulador de autorização
54
55
  dummy_authorization_handler: Verifique contra o manipulador de autorização de exemplo
55
56
  dummy_authorization_workflow: Verifique o exemplo de fluxo de trabalho de autorização
56
57
  id_documents: Seja verificado ao fazer o upload do documento de identidade
@@ -9,6 +9,13 @@ ru:
9
9
  document_type: Вид вашего документа
10
10
  user: Участник
11
11
  verification_attachment: Скан вашего документа
12
+ postal_letter_address:
13
+ full_address: Полный адрес
14
+ postal_letter_confirmation:
15
+ verification_code: Проверочный код
16
+ postal_letter_postage:
17
+ full_address: Полный адрес
18
+ verification_code: Проверочный код
12
19
  decidim:
13
20
  admin:
14
21
  menu:
@@ -44,6 +51,7 @@ ru:
44
51
  success: Вы успешно подтвердили свою личность.
45
52
  first_login:
46
53
  actions:
54
+ another_dummy_authorization_handler: Проведите подтверждение, сравнив с другим примером подтверждения личности
47
55
  dummy_authorization_handler: Проведите подтверждение, сравнив с примером подтверждения личности
48
56
  dummy_authorization_workflow: Проведите подтверждение, сравнив с примером пути подтверждения личности
49
57
  id_documents: Подтвердите личность, загрузив документ, удостоверяющий её
@@ -55,6 +63,12 @@ ru:
55
63
  authorize_with: Подтвердить личность с помощью %{authorizer}
56
64
  skip_verification: Вы можете пока что пропустить это и %{link}
57
65
  start_exploring: начать изучать
66
+ dummy_authorization:
67
+ extra_explanation:
68
+ one: Участие ограничено участниками с почтовым кодом %{postal_codes}.
69
+ few: 'Участие ограничено участниками с почтовыми кодами %{postal_codes}.'
70
+ many: 'Участие ограничено участниками с почтовыми кодами %{postal_codes}.'
71
+ other: 'Участие ограничено участниками с почтовыми кодами %{postal_codes}.'
58
72
  id_documents:
59
73
  admin:
60
74
  confirmations:
@@ -51,6 +51,7 @@ sv:
51
51
  success: Du har godkänts.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Verifiera mot ett annat exempel på behörighetshanteraren
54
55
  dummy_authorization_handler: Verifiera mot exemplet behörighetshanteraren
55
56
  dummy_authorization_workflow: Verifiera mot arbetsflödet för godkännande av exempel
56
57
  id_documents: Få verifierad genom att ladda upp ditt identitetsdokument
@@ -51,6 +51,7 @@ uk:
51
51
  success: Ви успішно підтвердили свою особу.
52
52
  first_login:
53
53
  actions:
54
+ another_dummy_authorization_handler: Підтвердьте, порівнявши з іншим прикладом підтвердження своєї особи
54
55
  dummy_authorization_handler: Підтвердьте, порівнявши з прикладом підтвердження своєї особи
55
56
  dummy_authorization_workflow: Підтвердьте, порівнявши з прикладом підтвердження своєї особи
56
57
  id_documents: Підтвердіть особу, завантаживши ваш документ
@@ -6,7 +6,6 @@ require "decidim/verifications/workflows"
6
6
 
7
7
  require "decidim/verifications/id_documents"
8
8
  require "decidim/verifications/postal_letter"
9
- require "decidim/verifications/dummy"
10
9
 
11
10
  module Decidim
12
11
  def self.authorization_workflows
@@ -4,7 +4,7 @@ module Decidim
4
4
  # This holds the decidim-verifications version.
5
5
  module Verifications
6
6
  def self.version
7
- "0.11.2"
7
+ "0.12.0.pre"
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "decidim/settings_manifest"
4
+
3
5
  module Decidim
4
6
  module Verifications
5
7
  autoload :DefaultActionAuthorizer, "decidim/verifications/default_action_authorizer"
@@ -63,6 +65,26 @@ module Decidim
63
65
  DefaultActionAuthorizer
64
66
  end
65
67
  end
68
+
69
+ # Public: Adds configurable settings for this verification workflow. It
70
+ # uses the DSL specified under `Decidim::SettingsManifest`.
71
+ #
72
+ # &block - The DSL present on `Decidim::SettingsManifest`
73
+ #
74
+ # Examples:
75
+ #
76
+ # workflow.options do |options|
77
+ # options.attribute :minimum_age, type: :integer, default: 18
78
+ # end
79
+ #
80
+ # Returns nothing.
81
+ def options
82
+ @options ||= SettingsManifest.new
83
+
84
+ yield(@options) if block_given?
85
+
86
+ @options
87
+ end
66
88
  end
67
89
  end
68
90
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: decidim-verifications
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.2
4
+ version: 0.12.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Rodriguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-13 00:00:00.000000000 Z
11
+ date: 2018-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: decidim-core
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.11.2
19
+ version: 0.12.0.pre
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.11.2
26
+ version: 0.12.0.pre
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: decidim-admin
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - '='
32
32
  - !ruby/object:Gem::Version
33
- version: 0.11.2
33
+ version: 0.12.0.pre
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - '='
39
39
  - !ruby/object:Gem::Version
40
- version: 0.11.2
40
+ version: 0.12.0.pre
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: decidim-dev
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 0.11.2
47
+ version: 0.12.0.pre
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 0.11.2
54
+ version: 0.12.0.pre
55
55
  description: Several verification methods for your decidim instance
56
56
  email:
57
57
  - deivid.rodriguez@riseup.net
@@ -82,7 +82,6 @@ files:
82
82
  - app/presenters/decidim/verifications/postal_letter/authorization_presenter.rb
83
83
  - app/queries/decidim/verifications/authorizations.rb
84
84
  - app/services/decidim/authorization_handler.rb
85
- - app/services/decidim/dummy_authorization_handler.rb
86
85
  - app/uploaders/decidim/verifications/attachment_uploader.rb
87
86
  - app/views/decidim/verifications/authorizations/_granted_authorization.html.erb
88
87
  - app/views/decidim/verifications/authorizations/first_login.html.erb
@@ -115,7 +114,6 @@ files:
115
114
  - lib/decidim/verifications.rb
116
115
  - lib/decidim/verifications/adapter.rb
117
116
  - lib/decidim/verifications/default_action_authorizer.rb
118
- - lib/decidim/verifications/dummy.rb
119
117
  - lib/decidim/verifications/engine.rb
120
118
  - lib/decidim/verifications/id_documents.rb
121
119
  - lib/decidim/verifications/id_documents/admin.rb
@@ -146,9 +144,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
146
144
  version: '0'
147
145
  required_rubygems_version: !ruby/object:Gem::Requirement
148
146
  requirements:
149
- - - ">="
147
+ - - ">"
150
148
  - !ruby/object:Gem::Version
151
- version: '0'
149
+ version: 1.3.1
152
150
  requirements: []
153
151
  rubyforge_project:
154
152
  rubygems_version: 2.7.6
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Decidim
4
- # An example implementation of an AuthorizationHandler to be used in tests.
5
- class DummyAuthorizationHandler < AuthorizationHandler
6
- attribute :document_number, String
7
- attribute :postal_code, String
8
- attribute :birthday, Date
9
-
10
- validates :document_number, presence: true
11
- validate :valid_document_number
12
-
13
- def metadata
14
- super.merge(document_number: document_number, postal_code: postal_code)
15
- end
16
-
17
- def unique_id
18
- document_number
19
- end
20
-
21
- private
22
-
23
- def valid_document_number
24
- errors.add(:document_number, :invalid) unless document_number.to_s.end_with?("X")
25
- end
26
-
27
- # An example implementation of a DefaultActionAuthorizer inherited class to override authorization status
28
- # checking process. In this case, it allows to set a list of valid postal codes for an authorization.
29
- class ActionAuthorizer < Decidim::Verifications::DefaultActionAuthorizer
30
- attr_reader :allowed_postal_codes
31
-
32
- # Overrides the parent class method, but it still uses it to keep the base behavior
33
- def authorize
34
- # Remove the additional setting from the options hash to avoid to be considered missing.
35
- @allowed_postal_codes ||= options.delete("allowed_postal_codes")
36
-
37
- status_code, data = *super
38
-
39
- if allowed_postal_codes.present?
40
- # Does not authorize users with different postal codes
41
- if status_code == :ok && !allowed_postal_codes.member?(authorization.metadata["postal_code"])
42
- status_code = :unauthorized
43
- data[:fields] = { "postal_code" => authorization.metadata["postal_code"] }
44
- end
45
-
46
- # Adds an extra message for inform the user the additional restriction for this authorization
47
- data[:extra_explanation] = { key: "extra_explanation",
48
- params: { scope: "decidim.verifications.dummy_authorization",
49
- count: allowed_postal_codes.count,
50
- postal_codes: allowed_postal_codes.join(", ") } }
51
- end
52
-
53
- [status_code, data]
54
- end
55
-
56
- # Adds the list of allowed postal codes to the redirect URL, to allow forms to inform about it
57
- def redirect_params
58
- { "postal_codes" => allowed_postal_codes&.join("-") }
59
- end
60
- end
61
- end
62
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Decidim::Verifications.register_workflow(:dummy_authorization_handler) do |workflow|
4
- workflow.form = "Decidim::DummyAuthorizationHandler"
5
- workflow.action_authorizer = "Decidim::DummyAuthorizationHandler::ActionAuthorizer"
6
- workflow.expires_in = 1.hour
7
- end