decidim-verifications 0.29.2 → 0.30.0.rc2

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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/app/commands/decidim/verifications/authorize_user.rb +24 -0
  3. data/app/commands/decidim/verifications/revoke_by_name_authorizations.rb +51 -0
  4. data/app/controllers/decidim/verifications/authorizations_controller.rb +73 -16
  5. data/app/controllers/decidim/verifications/id_documents/authorizations_controller.rb +3 -1
  6. data/app/forms/decidim/verifications/sms/mobile_phone_form.rb +1 -1
  7. data/app/helpers/decidim/verifications/application_helper.rb +28 -0
  8. data/app/models/decidim/verifications/conflict.rb +8 -0
  9. data/app/services/decidim/authorization_handler.rb +22 -1
  10. data/app/views/decidim/verifications/authorizations/_tos_acceptance_field.html.erb +11 -0
  11. data/app/views/decidim/verifications/authorizations/index.html.erb +4 -4
  12. data/app/views/decidim/verifications/authorizations/new.html.erb +14 -6
  13. data/app/views/decidim/verifications/authorizations/onboarding_pending.html.erb +38 -0
  14. data/app/views/decidim/verifications/id_documents/authorizations/choose.html.erb +2 -2
  15. data/app/views/decidim/verifications/id_documents/authorizations/edit.html.erb +1 -1
  16. data/app/views/decidim/verifications/id_documents/authorizations/new.html.erb +1 -1
  17. data/app/views/decidim/verifications/postal_letter/authorizations/edit.html.erb +2 -2
  18. data/app/views/decidim/verifications/postal_letter/authorizations/new.html.erb +1 -1
  19. data/app/views/decidim/verifications/sms/authorizations/edit.html.erb +1 -1
  20. data/app/views/decidim/verifications/sms/authorizations/new.html.erb +1 -1
  21. data/app/views/dummy_authorization/_form.html.erb +0 -6
  22. data/app/views/layouts/decidim/authorizations.html.erb +34 -0
  23. data/config/locales/ar.yml +10 -21
  24. data/config/locales/bg.yml +21 -36
  25. data/config/locales/ca.yml +38 -35
  26. data/config/locales/cs.yml +38 -35
  27. data/config/locales/de.yml +38 -35
  28. data/config/locales/el.yml +8 -22
  29. data/config/locales/en.yml +18 -15
  30. data/config/locales/es-MX.yml +39 -36
  31. data/config/locales/es-PY.yml +39 -36
  32. data/config/locales/es.yml +38 -35
  33. data/config/locales/eu.yml +39 -36
  34. data/config/locales/fi-plain.yml +38 -35
  35. data/config/locales/fi.yml +38 -35
  36. data/config/locales/fr-CA.yml +34 -36
  37. data/config/locales/fr.yml +34 -36
  38. data/config/locales/gl.yml +8 -24
  39. data/config/locales/hu.yml +10 -25
  40. data/config/locales/id-ID.yml +8 -21
  41. data/config/locales/is-IS.yml +8 -16
  42. data/config/locales/it.yml +8 -24
  43. data/config/locales/ja.yml +38 -36
  44. data/config/locales/lt.yml +10 -25
  45. data/config/locales/lv.yml +8 -22
  46. data/config/locales/nl.yml +8 -24
  47. data/config/locales/no.yml +8 -24
  48. data/config/locales/pl.yml +21 -36
  49. data/config/locales/pt-BR.yml +8 -24
  50. data/config/locales/pt.yml +8 -24
  51. data/config/locales/ro-RO.yml +8 -24
  52. data/config/locales/ru.yml +8 -17
  53. data/config/locales/sk.yml +8 -22
  54. data/config/locales/sv.yml +21 -34
  55. data/config/locales/tr-TR.yml +8 -23
  56. data/config/locales/uk.yml +8 -17
  57. data/config/locales/zh-CN.yml +8 -25
  58. data/config/locales/zh-TW.yml +10 -25
  59. data/decidim-verifications.gemspec +1 -1
  60. data/lib/decidim/verifications/adapter.rb +1 -1
  61. data/lib/decidim/verifications/engine.rb +22 -1
  62. data/lib/decidim/verifications/version.rb +1 -1
  63. data/lib/decidim/verifications/workflow_manifest.rb +1 -0
  64. metadata +13 -11
  65. data/app/views/decidim/verifications/authorizations/first_login.html.erb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49ff72a860fec85533ab436db4e7c70a262b27de8abbeea7ad177f65cbaaaa4f
4
- data.tar.gz: 912fa95af54afc87537d35134863392c3547792aa818573a580df748985e63ee
3
+ metadata.gz: dbf4b3cecf23032b6b5a0cb28d16a1ede3b1a33d6ce68026e52ed158e7de882f
4
+ data.tar.gz: c026654751a16bea277b65e560f16c9fdbcfa1fddcf0e5ee3f5e6909cba5f5f7
5
5
  SHA512:
6
- metadata.gz: b72c35d415950c125f9fafd24f2989293c76a74ff19d7e50a7c1af731df139cfedd2907b7494ce22eca2555b93a68aa8ba501e2641c54dca297160228b7444fd
7
- data.tar.gz: a7c472ec82128d09f7b27a8f99ebe6f4dc610c7704230684e8222136b3615776b5f8c18074ac9696e82438046c36203246b4c7d7c853254b3f32dbafc541f1aa
6
+ metadata.gz: c89002102986c8a645b88d9946b479db2cb4f1eda46c2fc626a2b3815597c75f90ea495bacecb1d8dbf4b1084c646268a3541d195188c97f1ad51a40a3f9fc7b
7
+ data.tar.gz: b821c2fa1cbfdb0d324efb821909a0460a29ff297b5bddb1aa14c55412238fd0dd6a8e6982c5452fcf238ab23e7380541b01932153438c5c55a9d44693781454
@@ -16,9 +16,22 @@ module Decidim
16
16
  #
17
17
  # - :ok when everything is valid.
18
18
  # - :invalid if the handler was not valid and we could not proceed.
19
+ # - :transferred if there is a duplicated authorization associated
20
+ # to other user and the authorization can be
21
+ # transferred.
22
+ # - :transfer_user if there is a duplicated authorization associated
23
+ # to an ephemeral user and the current user is also
24
+ # ephemeral the session is transferred to the user
25
+ # with the existing authorization
19
26
  #
20
27
  # Returns nothing.
21
28
  def call
29
+ if !handler.unique? && handler.user_transferrable?
30
+ handler.user = handler.duplicate.user
31
+ Authorization.create_or_update_from(handler)
32
+ return broadcast(:transfer_user, handler.user)
33
+ end
34
+
22
35
  return transfer_authorization if !handler.unique? && handler.transferrable?
23
36
 
24
37
  if handler.invalid?
@@ -27,6 +40,8 @@ module Decidim
27
40
  return broadcast(:invalid)
28
41
  end
29
42
 
43
+ return broadcast(:invalid) unless set_tos_agreement
44
+
30
45
  Authorization.create_or_update_from(handler)
31
46
 
32
47
  broadcast(:ok)
@@ -79,6 +94,15 @@ module Decidim
79
94
 
80
95
  conflict
81
96
  end
97
+
98
+ def set_tos_agreement
99
+ user = handler.user
100
+
101
+ return true if user.tos_accepted? || !user.ephemeral?
102
+ return unless handler.try(:tos_agreement)
103
+
104
+ user.update(accepted_tos_version: @organization.tos_version)
105
+ end
82
106
  end
83
107
  end
84
108
  end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decidim
4
+ module Verifications
5
+ # A command to revoke authorizations by name
6
+ class RevokeByNameAuthorizations < Decidim::Command
7
+ # Public: Initializes the command.
8
+ #
9
+ # organization - Organization object.
10
+ # name - Authorizations handler name
11
+ # current_user - The current user.
12
+ def initialize(organization, name, current_user)
13
+ @organization = organization
14
+ @current_user = current_user
15
+ @name = name
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, name].all?(&:present?)
26
+
27
+ auths = Decidim::Verifications::Authorizations.new(
28
+ organization:,
29
+ name:,
30
+ granted: true
31
+ ).query
32
+
33
+ auths.find_each do |auth|
34
+ Decidim.traceability.perform_action!(
35
+ :destroy,
36
+ auth,
37
+ current_user
38
+ ) do
39
+ auth.destroy
40
+ end
41
+ end
42
+
43
+ broadcast(:ok)
44
+ end
45
+
46
+ private
47
+
48
+ attr_reader :organization, :name, :current_user
49
+ end
50
+ end
51
+ end
@@ -5,8 +5,11 @@ module Decidim
5
5
  # This controller allows users to create and destroy their authorizations. It
6
6
  # should not be necessary to expand it to add new authorization schemes.
7
7
  class AuthorizationsController < Verifications::ApplicationController
8
- helper_method :handler, :unauthorized_methods, :authorization_method, :authorization
9
- before_action :valid_handler, only: [:new, :create]
8
+ helper_method :handler, :unauthorized_methods, :authorization_method, :authorization,
9
+ :granted_authorizations, :pending_authorizations, :active_authorization_methods
10
+
11
+ before_action :valid_handler, :authorize_handler, only: [:new, :create]
12
+ before_action :set_ephemeral_user, only: :renew_onboarding_data
10
13
 
11
14
  include Decidim::UserProfile
12
15
  include Decidim::HtmlSafeFlash
@@ -16,23 +19,40 @@ module Decidim
16
19
  helper Decidim::AuthorizationFormHelper
17
20
  helper Decidim::TranslationsHelper
18
21
 
19
- layout "layouts/decidim/authorizations", except: :index
22
+ layout "layouts/decidim/authorizations", except: [:index, :onboarding_pending]
20
23
 
21
24
  def new; end
22
25
 
23
- def index
24
- @granted_authorizations = granted_authorizations
25
- @pending_authorizations = pending_authorizations
26
- end
26
+ def index; end
27
+
28
+ def onboarding_pending
29
+ return redirect_back(fallback_location: authorizations_path) unless onboarding_manager.valid?
27
30
 
28
- def first_login
29
- if unauthorized_methods.length == 1
30
- redirect_to(
31
- action: :new,
32
- handler: unauthorized_methods.first.name,
33
- redirect_url: decidim.account_path
31
+ authorizations = action_authorized_to(onboarding_manager.action, **onboarding_manager.action_authorized_resources)
32
+
33
+ authorization_status = authorizations.global_code
34
+ if authorizations.single_authorization_required?
35
+ flash.keep
36
+ return redirect_to(authorizations.statuses.first.current_path(redirect_url: decidim_verifications.onboarding_pending_authorizations_path))
37
+ end
38
+ return unless onboarding_manager.finished_verifications?(active_authorization_methods) || authorization_status == :unauthorized
39
+
40
+ if authorization_status == :unauthorized
41
+ flash[:alert] = t("authorizations.onboarding_pending.unauthorized", scope: "decidim.verifications", action: onboarding_manager.action_text.downcase)
42
+ elsif current_user.ephemeral?
43
+ flash[:notice] = t("ephemeral_authorized_message", scope: "decidim.onboarding_action_message")
44
+ else
45
+ flash[:notice] = t(
46
+ "authorizations.onboarding_pending.completed_verifications",
47
+ scope: "decidim.verifications",
48
+ action: onboarding_manager.action_text.downcase,
49
+ resource_name: onboarding_manager.model_name.human.downcase
34
50
  )
35
51
  end
52
+
53
+ redirect_to onboarding_manager.finished_redirect_path
54
+
55
+ clear_onboarding_data!(current_user)
36
56
  end
37
57
 
38
58
  def create
@@ -57,6 +77,14 @@ module Decidim
57
77
  redirect_to redirect_url || authorizations_path
58
78
  end
59
79
 
80
+ on(:transfer_user) do |authorized_user|
81
+ authorized_user.update(last_sign_in_at: Time.current, deleted_at: nil)
82
+ sign_out(current_user)
83
+ sign_in(authorized_user)
84
+
85
+ redirect_to decidim_verifications.onboarding_pending_authorizations_path
86
+ end
87
+
60
88
  on(:invalid) do
61
89
  flash[:alert] = t("authorizations.create.error", scope: "decidim.verifications")
62
90
  render action: :new
@@ -64,6 +92,16 @@ module Decidim
64
92
  end
65
93
  end
66
94
 
95
+ def renew_onboarding_data
96
+ store_onboarding_cookie_data!(current_user)
97
+
98
+ redirect_to onboarding_pending_authorizations_path
99
+ end
100
+
101
+ def clear_onboarding_data
102
+ clear_onboarding_data!(current_user)
103
+ end
104
+
67
105
  protected
68
106
 
69
107
  def authorization_method(authorization)
@@ -103,6 +141,25 @@ module Decidim
103
141
  redirect_to(authorizations_path) && (return false)
104
142
  end
105
143
 
144
+ def authorize_handler
145
+ raise Decidim::ActionForbidden if current_user.ephemeral? && !Decidim::Verifications::Adapter.from_element(handler_name).ephemeral?
146
+ end
147
+
148
+ def set_ephemeral_user
149
+ return if user_signed_in?
150
+
151
+ onboarding_manager = Decidim::OnboardingManager.new(Decidim::User.new(extended_data: onboarding_cookie_data))
152
+ authorizations = action_authorized_to(onboarding_manager.action, **onboarding_manager.action_authorized_resources)
153
+ return unless authorizations.ephemeral?
154
+
155
+ form = Decidim::EphemeralUserForm.new(organization: current_organization, locale: current_locale)
156
+ CreateEphemeralUser.call(form) do
157
+ on(:ok) do |ephemeral_user|
158
+ sign_in(ephemeral_user)
159
+ end
160
+ end
161
+ end
162
+
106
163
  def unauthorized_methods
107
164
  @unauthorized_methods ||= available_verification_workflows.reject do |handler|
108
165
  active_authorization_methods.include?(handler.key)
@@ -110,15 +167,15 @@ module Decidim
110
167
  end
111
168
 
112
169
  def active_authorization_methods
113
- Authorizations.new(organization: current_organization, user: current_user).pluck(:name)
170
+ @active_authorization_methods ||= Authorizations.new(organization: current_organization, user: current_user).pluck(:name)
114
171
  end
115
172
 
116
173
  def granted_authorizations
117
- Authorizations.new(organization: current_organization, user: current_user, granted: true)
174
+ @granted_authorizations ||= Authorizations.new(organization: current_organization, user: current_user, granted: true)
118
175
  end
119
176
 
120
177
  def pending_authorizations
121
- Authorizations.new(organization: current_organization, user: current_user, granted: false)
178
+ @pending_authorizations ||= Authorizations.new(organization: current_organization, user: current_user, granted: false)
122
179
  end
123
180
 
124
181
  def store_current_location
@@ -14,7 +14,9 @@ module Decidim
14
14
  before_action :load_authorization
15
15
 
16
16
  def choose
17
- return redirect_to action: :new, using: verification_type if available_methods.count == 1
17
+ url_params = { redirect_url: }.compact
18
+
19
+ return redirect_to(action: :new, **url_params.merge(using: verification_type)) if available_methods.count == 1
18
20
 
19
21
  render :choose
20
22
  end
@@ -18,7 +18,7 @@ module Decidim
18
18
  # A mobile phone can only be verified once but it should be private.
19
19
  def unique_id
20
20
  Digest::MD5.hexdigest(
21
- "#{mobile_phone_number}-#{Rails.application.secrets.secret_key_base}"
21
+ "#{mobile_phone_number}-#{Rails.application.secret_key_base}"
22
22
  )
23
23
  end
24
24
 
@@ -47,6 +47,12 @@ module Decidim
47
47
  renew_modal_authorizations_path(handler: authorization.name)
48
48
  end
49
49
 
50
+ def authorizations_back_path(user, redirect_url: nil)
51
+ return redirect_url if redirect_url == decidim_verifications.onboarding_pending_authorizations_path && pending_onboarding_action?(user)
52
+
53
+ decidim_verifications.authorizations_path
54
+ end
55
+
50
56
  def granted_authorization_explanation(authorization)
51
57
  expiration_timestamp = authorization.expires_at.presence && l(authorization.expires_at, format: :long_with_particles)
52
58
  if authorization.expired?
@@ -86,6 +92,28 @@ module Decidim
86
92
  button_text: t("authorizations.index.subscribe", scope: "decidim.verifications")
87
93
  }
88
94
  end
95
+
96
+ def onboarding_sections(onboarding_manager, redirect_url: nil, granted_authorizations: nil, pending_authorizations: nil, unauthorized_methods: nil)
97
+ [
98
+ [
99
+ t("granted_verifications", scope: "decidim.verifications.authorizations.onboarding_pending"),
100
+ onboarding_manager.filter_authorizations(granted_authorizations),
101
+ :granted_authorization_display_data
102
+ ],
103
+ [
104
+ t("pending_admin_approval_verifications", scope: "decidim.verifications.authorizations.onboarding_pending"),
105
+ onboarding_manager.filter_authorizations(pending_authorizations),
106
+ :pending_authorization_display_data
107
+ ],
108
+ [
109
+ t("pending_verifications", scope: "decidim.verifications.authorizations.onboarding_pending"),
110
+ onboarding_manager.filter_authorizations(unauthorized_methods),
111
+ :unauthorized_method_display_data
112
+ ]
113
+ ].filter_map do |title, authorizations, presenter|
114
+ { title:, items: authorizations.map { |authorization| send(presenter, authorization, redirect_url) } } if authorizations.present?
115
+ end
116
+ end
89
117
  end
90
118
  end
91
119
  end
@@ -4,5 +4,13 @@ module Decidim::Verifications
4
4
  class Conflict < ApplicationRecord
5
5
  belongs_to :current_user, class_name: "User"
6
6
  belongs_to :managed_user, class_name: "User"
7
+
8
+ def self.ransackable_attributes(_auth_object = nil)
9
+ []
10
+ end
11
+
12
+ def self.ransackable_associations(_auth_object = nil)
13
+ %w(current_user)
14
+ end
7
15
  end
8
16
  end
@@ -20,7 +20,10 @@ module Decidim
20
20
  # infer the class name of the authorization handler.
21
21
  attribute :handler_name, String
22
22
 
23
+ attribute :tos_agreement, Boolean
24
+
23
25
  validate :uniqueness
26
+ validates :tos_agreement, allow_nil: false, acceptance: true, if: :ephemeral_tos_pending?
24
27
 
25
28
  # A unique ID to be implemented by the authorization handler that ensures
26
29
  # no duplicates are created. This uniqueness check will be skipped if
@@ -47,6 +50,15 @@ module Decidim
47
50
  duplicate.present? && duplicate.user.deleted?
48
51
  end
49
52
 
53
+ # Defines whether the identity of an ephemeral user with the same authorization
54
+ # can be transferred to the current session and replace the existing user.
55
+ #
56
+ # @return [Boolean] A boolean indicating whether the user identifier can be
57
+ # transferred.
58
+ def user_transferrable?
59
+ duplicate.present? && [user, duplicate.user].all?(&:ephemeral?)
60
+ end
61
+
50
62
  # Fetches the duplicate record of the same authorization currently belonging
51
63
  # to other user than the user being authorized.
52
64
  #
@@ -67,7 +79,10 @@ module Decidim
67
79
  #
68
80
  # Returns an Array of Strings.
69
81
  def form_attributes
70
- attributes.except("id", "user").keys
82
+ excluded = %w(id user)
83
+ excluded << "tos_agreement" unless ephemeral_tos_pending?
84
+
85
+ attributes.except(*excluded).keys
71
86
  end
72
87
 
73
88
  # The String partial path so Rails can render the handler as a form. This
@@ -155,6 +170,12 @@ module Decidim
155
170
  manifest.form.constantize.from_params(params || {})
156
171
  end
157
172
 
173
+ def ephemeral_tos_pending?
174
+ return if user.blank?
175
+
176
+ user.ephemeral? && !user.tos_accepted?
177
+ end
178
+
158
179
  private
159
180
 
160
181
  def uniqueness
@@ -0,0 +1,11 @@
1
+ <div id="card__tos" class="form__wrapper-block">
2
+ <h2 class="h4"><%= t("decidim.devise.registrations.new.tos_title") %></h2>
3
+
4
+ <div>
5
+ <% terms_of_service_summary_content_blocks.each do |content_block| %>
6
+ <%= cell content_block.manifest.cell, content_block %>
7
+ <% end %>
8
+ </div>
9
+
10
+ <%= form.check_box :tos_agreement, label: t("decidim.verifications.authorizations.new.tos_agreement", link: link_to(t("decidim.devise.registrations.new.terms"), decidim.page_path("terms-of-service"))), label_options: { class: "form__wrapper-checkbox-label" } %>
11
+ </div>
@@ -12,13 +12,13 @@
12
12
 
13
13
  subsections << {
14
14
  title: t("authorizations.index.granted_verification", scope: "decidim.verifications"),
15
- items: @granted_authorizations.map { |authorization| granted_authorization_display_data(authorization, redirect_url) }
16
- } if @granted_authorizations.any?
15
+ items: granted_authorizations.map { |authorization| granted_authorization_display_data(authorization, redirect_url) }
16
+ } if granted_authorizations.any?
17
17
 
18
18
  subsections << {
19
19
  title: t("authorizations.index.pending_verification", scope: "decidim.verifications"),
20
- items: @pending_authorizations.map { |authorization| pending_authorization_display_data(authorization, redirect_url) }
21
- } if @pending_authorizations.any?
20
+ items: pending_authorizations.map { |authorization| pending_authorization_display_data(authorization, redirect_url) }
21
+ } if pending_authorizations.any?
22
22
 
23
23
  subsections << {
24
24
  title: t("authorizations.index.unauthorized_methods", scope: "decidim.verifications"),
@@ -13,10 +13,16 @@
13
13
  </div>
14
14
  <% end %>
15
15
 
16
+ <% if current_user.ephemeral? && !current_user.tos_accepted? %>
17
+ <%= render partial: "tos_acceptance_field", locals: { form: } %>
18
+ <% end %>
19
+
16
20
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
17
- <%= link_to authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
18
- <%= icon "arrow-left-line", class: "fill-current" %>
19
- <span><%= t("decidim.wizard_step_form.wizard_aside.back") %></span>
21
+ <% if onboarding_manager.available_authorization_selection_page? %>
22
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
23
+ <%= icon "arrow-left-line", class: "fill-current" %>
24
+ <span><%= t("decidim.wizard_step_form.wizard_aside.back") %></span>
25
+ <% end %>
20
26
  <% end %>
21
27
  <button type="submit" class="button button__sm md:button__lg button__secondary">
22
28
  <span><%= t("decidim.verifications.authorizations.new.authorize") %></span>
@@ -24,7 +30,9 @@
24
30
  </button>
25
31
  </div>
26
32
 
27
- <p class="prose prose-a:text-secondary">
28
- <%= t("decidim.verifications.authorizations.skip_verification", link: link_to(t("decidim.verifications.authorizations.start_exploring"), cta_button_path).html_safe).html_safe %>.
29
- </p>
33
+ <% unless onboarding_manager.ephemeral? %>
34
+ <p class="prose prose-a:text-secondary">
35
+ <%= t("decidim.verifications.authorizations.skip_verification", link: link_to(t("decidim.verifications.authorizations.start_exploring"), cta_button_path).html_safe).html_safe %>.
36
+ </p>
37
+ <% end %>
30
38
  <% end %>
@@ -0,0 +1,38 @@
1
+ <% add_decidim_page_title(t("authorizations", scope: "layouts.decidim.user_profile")) %>
2
+ <% content_for(:subtitle) { t("authorizations", scope: "layouts.decidim.user_profile") } %>
3
+ <% redirect_url = onboarding_pending_authorizations_path %>
4
+
5
+ <%= append_javascript_pack_tag "decidim_verifications" %>
6
+ <%= append_stylesheet_pack_tag "decidim_verifications" %>
7
+
8
+ <%= render layout: "layouts/decidim/shared/layout_center" do %>
9
+ <div class="py-10">
10
+ <%= t(
11
+ "onboarding_message_html",
12
+ scope: "decidim.verifications.authorizations.onboarding_pending",
13
+ action: onboarding_manager.action_text.downcase,
14
+ resource_name: onboarding_manager.model_name.human.downcase,
15
+ resource_title: translated_attribute(onboarding_manager.model_title)
16
+ ) %>
17
+ </div>
18
+
19
+ <section class="authorizations-list">
20
+ <% onboarding_sections(
21
+ onboarding_manager,
22
+ redirect_url:,
23
+ granted_authorizations:,
24
+ pending_authorizations:,
25
+ unauthorized_methods:
26
+ ).each do |section| %>
27
+ <div class="verification__container-title"><%= section[:title] %></div>
28
+ <div class="verification__container my-4">
29
+ <% section[:items].each do |locals| %>
30
+ <%= render partial: "item", locals: %>
31
+ <% end %>
32
+ </div>
33
+ <% end %>
34
+ </section>
35
+ <p class="prose prose-a:text-secondary">
36
+ <%= t("decidim.verifications.authorizations.skip_verification", link: link_to(t("decidim.verifications.authorizations.start_exploring"), cta_button_path).html_safe).html_safe %>.
37
+ </p>
38
+ <% end %>
@@ -7,6 +7,6 @@
7
7
  <p><%= t("decidim.verifications.id_documents.authorizations.choose.choose_a_type") %></p>
8
8
 
9
9
  <div class="mt-4 flex justify-between">
10
- <%= link_to t("decidim.verifications.id_documents.authorizations.choose.offline"), { action: :new, using: :offline }, class: "button button__sm md:button__lg button__transparent-secondary" %>
11
- <%= link_to t("decidim.verifications.id_documents.authorizations.choose.online"), { action: :new, using: :online }, class: "button button__sm md:button__lg button__secondary" %>
10
+ <%= link_to t("decidim.verifications.id_documents.authorizations.choose.offline"), { action: :new, using: :offline, redirect_url: }.compact, class: "button button__sm md:button__lg button__transparent-secondary" %>
11
+ <%= link_to t("decidim.verifications.id_documents.authorizations.choose.online"), { action: :new, using: :online, redirect_url: }.compact, class: "button button__sm md:button__lg button__secondary" %>
12
12
  </div>
@@ -18,7 +18,7 @@
18
18
  <%= render partial: "form", locals: { form: } %>
19
19
 
20
20
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
21
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
21
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
22
22
  <%= icon "arrow-left-line", class: "fill-current" %>
23
23
  <span><%= t("decidim.wizard_step_form.wizard_aside.back") %></span>
24
24
  <% end %>
@@ -10,7 +10,7 @@
10
10
  <%= render partial: "form", locals: { form: } %>
11
11
 
12
12
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
13
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
13
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
14
14
  <%= icon "arrow-left-line", class: "fill-current" %>
15
15
  <%= t("decidim.wizard_step_form.wizard_aside.back") %>
16
16
  <% end %>
@@ -13,7 +13,7 @@
13
13
  </div>
14
14
 
15
15
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
16
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
16
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
17
17
  <%= icon "arrow-left-line", class: "fill-current" %>
18
18
  <span><%= t("decidim.wizard_step_form.wizard_aside.back") %></span>
19
19
  <% end %>
@@ -29,7 +29,7 @@
29
29
  </div>
30
30
 
31
31
  <div class="form__wrapper-block">
32
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary mr-auto" do %>
32
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
33
33
  <%= icon "arrow-left-line", class: "fill-current" %>
34
34
  <%= t("decidim.wizard_step_form.wizard_aside.back") %>
35
35
  <% end %>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
 
14
14
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
15
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
15
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
16
16
  <%= icon "arrow-left-line", class: "fill-current" %>
17
17
  <%= t("decidim.wizard_step_form.wizard_aside.back") %>
18
18
  <% end %>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
 
14
14
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
15
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
15
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
16
16
  <%= icon "arrow-left-line", class: "fill-current" %>
17
17
  <span><%= t("decidim.wizard_step_form.wizard_aside.back") %></span>
18
18
  <% end %>
@@ -12,7 +12,7 @@
12
12
  </div>
13
13
 
14
14
  <div class="form__wrapper-block flex-col-reverse md:flex-row justify-between">
15
- <%= link_to decidim_verifications.authorizations_path, class: "button button__sm md:button__lg button__text-secondary" do %>
15
+ <%= link_to authorizations_back_path(current_user, redirect_url:), class: "button button__sm md:button__lg button__text-secondary" do %>
16
16
  <%= icon "arrow-left-line", class: "fill-current" %>
17
17
  <span><%= t("decidim.wizard_step_form.wizard_aside.back") %></span>
18
18
  <% end %>
@@ -3,10 +3,6 @@
3
3
  <p><%= t("extra_explanation.postal_codes", scope: "decidim.verifications.dummy_authorization", postal_codes: postal_codes.join(", "), count: postal_codes.count, user_postal_code: request["user_postal_code"]) %></p>
4
4
  <% end %>
5
5
 
6
- <% if request["scope"] && (scope = Decidim::Scope.find(request["scope"]&.to_i)) %>
7
- <p><%= t("extra_explanation.scope", scope: "decidim.verifications.dummy_authorization", scope_name: translated_attribute(scope.name), user_scope_name: request["user_scope_name"]) %></p>
8
- <% end %>
9
-
10
6
  <div class="form__wrapper" data-partial-demo>
11
7
  <%= form.hidden_field :handler_name %>
12
8
  <%= form.text_field :document_number %>
@@ -14,6 +10,4 @@
14
10
  <div class="row">
15
11
  <%= form.date_field :birthday %>
16
12
  </div>
17
- <%= scopes_select_field(form, :scope_id) %>
18
13
  </div>
19
- git
@@ -3,6 +3,40 @@
3
3
 
4
4
  <%= render "layouts/decidim/application" do %>
5
5
  <%= render layout: "layouts/decidim/shared/layout_center" do %>
6
+ <% if onboarding_manager.valid? %>
7
+ <% authorizations = action_authorized_to(onboarding_manager.action, **onboarding_manager.action_authorized_resources) %>
8
+ <% if authorizations.single_authorization_required? && is_active_link?(authorizations.statuses.first.current_path) %>
9
+ <% if current_user.ephemeral? %>
10
+ <%= cell(
11
+ "decidim/announcement",
12
+ t("pending_ephemeral_authorization", scope: "decidim.onboarding_action_message"),
13
+ callout_class: "warning"
14
+ ) %>
15
+ <% else %>
16
+ <%= cell(
17
+ "decidim/announcement",
18
+ {
19
+ title: case authorizations.statuses.first.code
20
+ when :expired
21
+ t("expired_authorization_active_title", scope: "decidim.onboarding_action_message")
22
+ when :incomplete
23
+ t("incomplete_authorization_active_title", scope: "decidim.onboarding_action_message")
24
+ else
25
+ t("pending_authorization_active_title", scope: "decidim.onboarding_action_message")
26
+ end,
27
+ body: t(
28
+ "pending_authorization_active_message",
29
+ scope: "decidim.onboarding_action_message",
30
+ action: onboarding_manager.action_text.downcase,
31
+ resource_name: onboarding_manager.model_name.human.downcase,
32
+ resource_title: decidim_sanitize_translated(onboarding_manager.model_title)
33
+ )
34
+ },
35
+ callout_class: "warning"
36
+ ) %>
37
+ <% end %>
38
+ <% end %>
39
+ <% end %>
6
40
  <%= yield %>
7
41
  <% end %>
8
42
  <% end %>