Skip to content

Commit

Permalink
Fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
sinaeftekhar committed Oct 3, 2023
2 parents 1c60f99 + eb32ad8 commit d3f944a
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/mainio/decidim-sms-telia.git
revision: 60cd4884aafe6fdbc687e024b20a3f4e70023c99
revision: 1f9415d8c04bb9c044c4374d0d360ef5369d3b26
branch: main
specs:
decidim-sms-telia (0.27.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,18 @@ def update_authorization!
end

def unique_id
"helsinki_smsauth_#{prefix}_#{form.access_code}"
Digest::MD5.hexdigest(
"helsinki_smsauth_#{random_prefix}_#{form.access_code}"
)
end

def prefix
characters = ("0".."9").to_a + ("A".."Z").to_a
characters.sample(10).join
# Since we do not have anything uniquely identifiying users, we need
# to provide a random prefix for the codes because the used codes are
# destroyed from the database, so it is theoretically possible two
# users would use the exact same code at some point.
def random_prefix
characters = ("0".."9").to_a + ("A".."Z").to_a + ("a".."z").to_a
64.times.map { characters.sample }.join
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def ensure_authorized
end

def find_user!
Decidim::User.find_by(
Decidim::User.unscoped.find_by(
phone_number: PhoneNumberFormatter.new(default_params[:phone_number]).format,
organization: current_organization
)
Expand Down
2 changes: 1 addition & 1 deletion app/models/decidim/helsinki_smsauth/signin_code_session.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
module Decidim
module HelsinkiSmsauth
class SigninCodeSession < ApplicationRecord
belongs_to :user, foreign_key: "decidim_user_id", class_name: "Decidim::User"
belongs_to :user, -> { respond_to?(:entire_collection) ? entire_collection : self }, foreign_key: "decidim_user_id", class_name: "Decidim::User"
belongs_to :signin_code_set, foreign_key: "decidim_signin_code_set_id", class_name: "::Decidim::HelsinkiSmsauth::SigninCodeSet"
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/decidim/helsinki_smsauth/signin_code_set.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class SigninCodeSet < ApplicationRecord

attribute :metadata, type: :hash

belongs_to :creator, foreign_key: "decidim_user_id", class_name: "Decidim::User"
belongs_to :creator, -> { respond_to?(:entire_collection) ? entire_collection : self }, foreign_key: "decidim_user_id", class_name: "Decidim::User"
has_many :signin_codes, foreign_key: "decidim_signin_code_set_id", class_name: "Decidim::HelsinkiSmsauth::SigninCode", dependent: :destroy

validates :generated_code_amount, numericality: { greater_than: 0 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
</div>
<div class="row">
<div class="columns medium-8">
<button class="button expanded" data-close type="button">
<button class="button hollow expanded" data-close type="button">
<%= t("cancel", scope: scope) %>
</button>
</div>
<div class="columns medium-8">
<%= link_to t("exit_modal", scope: scope), signin_code_sets_path, id: "exit-notification-link", class: "button hollow expanded" %>
<%= link_to t("exit_modal", scope: scope), signin_code_sets_path, id: "exit-notification-link", class: "button expanded" %>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion config/locales/fi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fi:
generate_codes: Luo koodeja
title: Luo koodeja
view_generated_codes:
access_code: Kirjautumiskoodi
expiration_note: Nämä koodit vanhenevat %{expiration_time}
access_codes: Kirjautumiskoodit
continue: Jatka
download_as_csv: Lataa CSV
Expand Down
2 changes: 1 addition & 1 deletion config/locales/sv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ sv:
generate_codes: Skapa koder
title: Skapa koder
view_generated_codes:
access_code: Inloggningskod
expiration_note: Dessa koder upphör att gälla %{expiration_time}
access_codes: Inloggningskoder
continue: Fortsätta
download_as_csv: Ladda ner CSV
Expand Down
2 changes: 1 addition & 1 deletion spec/system/verification_with_phone_number_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
name: "helsinki_smsauth_id",
user: another_user,
metadata: auth_metadata,
unique_id: "36622e90d8c073ac33cfa896610632a9"
unique_id: Digest::MD5.hexdigest("FI-4567890-#{Rails.application.secrets.secret_key_base}")
)
end

Expand Down

0 comments on commit d3f944a

Please sign in to comment.