Skip to content

Commit 63cabec

Browse files
authored
fix inconsistency schema.rb and minor other bugs(#1172)
* write a migration to add the order_total column back to the orders table if it does not already exist. * make zatladder work * accept otp code drift of 1 * fix suggestions * use bigger drift
1 parent ad4f2d7 commit 63cabec

File tree

5 files changed

+11
-5
lines changed

5 files changed

+11
-5
lines changed

app/controllers/callbacks_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def check_identity_with_otp(sofia_account, user)
4343
if params[:verification_code].blank?
4444
# OTP code not present, so request it
4545
render(json: { state: 'otp_prompt' })
46-
elsif sofia_account.authenticate_otp(params[:verification_code])
46+
elsif sofia_account.authenticate_otp(params[:verification_code], drift: 60)
4747
# OTP code correct
4848
sign_in(:user, user)
4949
render(json: { state: 'logged_in', redirect_url: user.roles.any? ? root_path : user_path(user.id) })

app/controllers/sofia_accounts_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def enable_otp # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
5959

6060
begin
6161
flash_message =
62-
if @sofia_account.authenticate_otp(params.require(:verification_code))
62+
if @sofia_account.authenticate_otp(params.require(:verification_code), drift: 60)
6363
if @sofia_account.update(otp_enabled: true)
6464
{ success: 'Two-factor-authenticatie aangezet!' }
6565
else

app/controllers/zatladder_controller.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,9 @@ def current_year
2424
end
2525

2626
def zatladder_spendings(from, to)
27-
@users_spendings = User.in_amber.calculate_spendings(from:, to:)
28-
zatladder = User.in_amber.select(:id, :name).map do |user|
27+
users = User.in_amber.exists? ? User.in_amber : User.sofia_account
28+
@users_spendings = users.calculate_spendings(from:, to:)
29+
zatladder = users.select(:id, :name).map do |user|
2930
{
3031
id: user.id,
3132
name: user.name,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class AddOrderTotalBackToOrders < ActiveRecord::Migration[7.2]
2+
def change
3+
add_column :orders, :order_total, :decimal, precision: 8, scale: 2 unless column_exists?(:orders, :order_total)
4+
end
5+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema[7.2].define(version: 2025_12_09_160709) do
13+
ActiveRecord::Schema[7.2].define(version: 2025_12_12_000001) do
1414
# These are extensions that must be enabled in order to support this database
1515
enable_extension "plpgsql"
1616

0 commit comments

Comments
 (0)