From 68aec582c29b0716902bddc33eb5ce8eff40c724 Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Fri, 12 Dec 2025 13:19:17 +0100 Subject: [PATCH 1/5] write a migration to add the order_total column back to the orders table if it does not already exist. --- db/migrate/20251212000001_add_order_total_back_to_orders.rb | 5 +++++ db/schema.rb | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20251212000001_add_order_total_back_to_orders.rb diff --git a/db/migrate/20251212000001_add_order_total_back_to_orders.rb b/db/migrate/20251212000001_add_order_total_back_to_orders.rb new file mode 100644 index 000000000..7fd06747c --- /dev/null +++ b/db/migrate/20251212000001_add_order_total_back_to_orders.rb @@ -0,0 +1,5 @@ +class AddOrderTotalBackToOrders < ActiveRecord::Migration[7.2] + def change + add_column :orders, :order_total, :decimal, precision: 8, scale: 2 unless column_exists?(:orders, :order_total) + end +end diff --git a/db/schema.rb b/db/schema.rb index 55b7e7575..8e64bb1a8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_12_09_160709) do +ActiveRecord::Schema[7.2].define(version: 2025_12_12_000001) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 70cb2c7444028bda0d4a6a765d361cc3249a4f16 Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Fri, 12 Dec 2025 13:30:24 +0100 Subject: [PATCH 2/5] make zatladder work --- app/controllers/zatladder_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/zatladder_controller.rb b/app/controllers/zatladder_controller.rb index 34093dd83..5d936eebe 100644 --- a/app/controllers/zatladder_controller.rb +++ b/app/controllers/zatladder_controller.rb @@ -24,8 +24,9 @@ def current_year end def zatladder_spendings(from, to) - @users_spendings = User.in_amber.calculate_spendings(from:, to:) - zatladder = User.in_amber.select(:id, :name).map do |user| + users = User.in_amber.any? ? User.in_amber : User.sofia_account + @users_spendings = users.calculate_spendings(from:, to:) + zatladder = users.select(:id, :name).map do |user| { id: user.id, name: user.name, From 32358777933af393f7c0ec1c28eb9e92abb15b10 Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Fri, 12 Dec 2025 13:46:52 +0100 Subject: [PATCH 3/5] accept otp code drift of 1 --- app/controllers/callbacks_controller.rb | 2 +- app/controllers/sofia_accounts_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/callbacks_controller.rb b/app/controllers/callbacks_controller.rb index 024d727f9..982aa87bd 100644 --- a/app/controllers/callbacks_controller.rb +++ b/app/controllers/callbacks_controller.rb @@ -43,7 +43,7 @@ def check_identity_with_otp(sofia_account, user) if params[:verification_code].blank? # OTP code not present, so request it render(json: { state: 'otp_prompt' }) - elsif sofia_account.authenticate_otp(params[:verification_code]) + elsif sofia_account.authenticate_otp(params[:verification_code], drift: 1) # OTP code correct sign_in(:user, user) render(json: { state: 'logged_in', redirect_url: user.roles.any? ? root_path : user_path(user.id) }) diff --git a/app/controllers/sofia_accounts_controller.rb b/app/controllers/sofia_accounts_controller.rb index 7493d3375..ec37eabf3 100644 --- a/app/controllers/sofia_accounts_controller.rb +++ b/app/controllers/sofia_accounts_controller.rb @@ -59,7 +59,7 @@ def enable_otp # rubocop:disable Metrics/AbcSize, Metrics/MethodLength begin flash_message = - if @sofia_account.authenticate_otp(params.require(:verification_code)) + if @sofia_account.authenticate_otp(params.require(:verification_code), drift: 1) if @sofia_account.update(otp_enabled: true) { success: 'Two-factor-authenticatie aangezet!' } else From 60dd35013df4f25bb1b3df91e026d497e05081aa Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Tue, 16 Dec 2025 21:29:02 +0100 Subject: [PATCH 4/5] fix suggestions --- app/controllers/callbacks_controller.rb | 2 +- app/controllers/sofia_accounts_controller.rb | 2 +- app/controllers/zatladder_controller.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/controllers/callbacks_controller.rb b/app/controllers/callbacks_controller.rb index 982aa87bd..002205f4a 100644 --- a/app/controllers/callbacks_controller.rb +++ b/app/controllers/callbacks_controller.rb @@ -43,7 +43,7 @@ def check_identity_with_otp(sofia_account, user) if params[:verification_code].blank? # OTP code not present, so request it render(json: { state: 'otp_prompt' }) - elsif sofia_account.authenticate_otp(params[:verification_code], drift: 1) + elsif sofia_account.authenticate_otp(params[:verification_code], drift: 30) # OTP code correct sign_in(:user, user) render(json: { state: 'logged_in', redirect_url: user.roles.any? ? root_path : user_path(user.id) }) diff --git a/app/controllers/sofia_accounts_controller.rb b/app/controllers/sofia_accounts_controller.rb index ec37eabf3..5fcf06a69 100644 --- a/app/controllers/sofia_accounts_controller.rb +++ b/app/controllers/sofia_accounts_controller.rb @@ -59,7 +59,7 @@ def enable_otp # rubocop:disable Metrics/AbcSize, Metrics/MethodLength begin flash_message = - if @sofia_account.authenticate_otp(params.require(:verification_code), drift: 1) + if @sofia_account.authenticate_otp(params.require(:verification_code), drift: 30) if @sofia_account.update(otp_enabled: true) { success: 'Two-factor-authenticatie aangezet!' } else diff --git a/app/controllers/zatladder_controller.rb b/app/controllers/zatladder_controller.rb index 5d936eebe..b9c4e3c3d 100644 --- a/app/controllers/zatladder_controller.rb +++ b/app/controllers/zatladder_controller.rb @@ -24,7 +24,7 @@ def current_year end def zatladder_spendings(from, to) - users = User.in_amber.any? ? User.in_amber : User.sofia_account + users = User.in_amber.exists? ? User.in_amber : User.sofia_account @users_spendings = users.calculate_spendings(from:, to:) zatladder = users.select(:id, :name).map do |user| { From 038356660afb76b1c5ad1796378d16a258356b6a Mon Sep 17 00:00:00 2001 From: Lodewiges Date: Tue, 16 Dec 2025 22:45:56 +0100 Subject: [PATCH 5/5] use bigger drift --- app/controllers/callbacks_controller.rb | 2 +- app/controllers/sofia_accounts_controller.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/callbacks_controller.rb b/app/controllers/callbacks_controller.rb index 002205f4a..cecd25ef2 100644 --- a/app/controllers/callbacks_controller.rb +++ b/app/controllers/callbacks_controller.rb @@ -43,7 +43,7 @@ def check_identity_with_otp(sofia_account, user) if params[:verification_code].blank? # OTP code not present, so request it render(json: { state: 'otp_prompt' }) - elsif sofia_account.authenticate_otp(params[:verification_code], drift: 30) + elsif sofia_account.authenticate_otp(params[:verification_code], drift: 60) # OTP code correct sign_in(:user, user) render(json: { state: 'logged_in', redirect_url: user.roles.any? ? root_path : user_path(user.id) }) diff --git a/app/controllers/sofia_accounts_controller.rb b/app/controllers/sofia_accounts_controller.rb index 5fcf06a69..c38ab988d 100644 --- a/app/controllers/sofia_accounts_controller.rb +++ b/app/controllers/sofia_accounts_controller.rb @@ -59,7 +59,7 @@ def enable_otp # rubocop:disable Metrics/AbcSize, Metrics/MethodLength begin flash_message = - if @sofia_account.authenticate_otp(params.require(:verification_code), drift: 30) + if @sofia_account.authenticate_otp(params.require(:verification_code), drift: 60) if @sofia_account.update(otp_enabled: true) { success: 'Two-factor-authenticatie aangezet!' } else