Enable devise lockable module with default values

In order to the display a warn text on the last attempt
before the account is locked, we need update
config.paranoid to false as the devise documentation
explains.

Adding "config.paranoid: false" implies further changes
to the code, so for now we unncomment the default value
"config.last_attempt_warning = true" and update it to false.
This commit is contained in:
taitus
2023-10-09 09:45:22 +02:00
parent 7c771b28b5
commit a1955531e1
5 changed files with 47 additions and 7 deletions

View File

@@ -0,0 +1,11 @@
class AddLockableToDevise < ActiveRecord::Migration[6.1]
def change
# Only if lock strategy is :failed_attempts
add_column :users, :failed_attempts, :integer, default: 0, null: false
add_column :users, :locked_at, :datetime
# Add these only if unlock strategy is :email or :both
add_column :users, :unlock_token, :string
add_index :users, :unlock_token, unique: true
end
end

View File

@@ -1644,6 +1644,9 @@ ActiveRecord::Schema.define(version: 2023_10_12_141318) do
t.boolean "recommended_debates", default: true
t.boolean "recommended_proposals", default: true
t.string "subscriptions_token"
t.integer "failed_attempts", default: 0, null: false
t.datetime "locked_at"
t.string "unlock_token"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["date_of_birth"], name: "index_users_on_date_of_birth"
t.index ["email"], name: "index_users_on_email", unique: true
@@ -1652,6 +1655,7 @@ ActiveRecord::Schema.define(version: 2023_10_12_141318) do
t.index ["hidden_at"], name: "index_users_on_hidden_at"
t.index ["password_changed_at"], name: "index_users_on_password_changed_at"
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
t.index ["username"], name: "index_users_on_username"
end