-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Redirect user to where she was after verification (#21)
* FEAT: Redirect user to where she was after verification * Rubocopify * FEAT: Autosubmit form * Enable this Authorization to appear in the Admin/Participants menu option * I18N: Add catalan translations * Update doc * I18N: Fix :es translation
- Loading branch information
1 parent
2074fe9
commit 081ac7e
Showing
32 changed files
with
279 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
app/commands/decidim/verifications/csv_email/confirm_csv_email_user_authorization.rb
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
app/controllers/decidim/verifications/csv_email/authorizations_controller.rb
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
app/decorators/lib/decidim/verifications/adapter_decorator.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# frozen_string_literal: true | ||
|
||
Decidim::Verifications::Adapter.class_eval do | ||
# | ||
# Administrational entry point for the verification engine | ||
# | ||
def admin_root_path | ||
admin_engine.send(:root_path, redirect_params) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# frozen_string_literal: true | ||
|
||
# A form object to be used when public users want to get verified by | ||
# CsvEmail verificator | ||
class CsvEmailAuthorizationHandler < Decidim::AuthorizationHandler | ||
# This is the input (from the user) to validate against | ||
attribute :email, String | ||
|
||
# This is the validation to perform | ||
# If passed, an authorization is created | ||
validates :email, presence: true | ||
validate :censed | ||
|
||
def unique_id | ||
Digest::SHA256.hexdigest( | ||
"#{user&.decidim_organization_id}-#{user.email}-#{handler_name}-#{Rails.application.secrets.secret_key_base}" | ||
) | ||
end | ||
|
||
# Checks if the email belongs to the census | ||
def censed | ||
return if (email == user.email) && (census_for_user&.email == email) | ||
|
||
if email != user.email | ||
errors.add(:email, I18n.t("decidim.verifications.csv_email.errors.messages.not_same_email")) | ||
else | ||
errors.add(:email, I18n.t("decidim.verifications.csv_email.errors.messages.not_in_csv")) | ||
end | ||
end | ||
|
||
def authorized? | ||
return true if census_for_user | ||
end | ||
|
||
def census_for_user | ||
@census_for_user ||= Decidim::Verifications::CsvEmail::CsvEmailDatum | ||
.search_user_email(organization, email) | ||
end | ||
|
||
def organization | ||
current_organization || user&.organization | ||
end | ||
end |
49 changes: 0 additions & 49 deletions
49
app/forms/decidim/verifications/csv_email/csv_email_form.rb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
|
||
# frozen_string_literal: true | ||
|
||
module Decidim | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.