From e79428fa289edbf7c556c2da059d9736dd339bcc Mon Sep 17 00:00:00 2001 From: Matchu Date: Sun, 6 Aug 2023 18:03:06 -0700 Subject: [PATCH] Add Remember Me to login This requires a migration, our first migration against the openneo_id database from this app! Fun! --- app/models/auth_user.rb | 3 ++- config/database.yml | 2 ++ .../20230807005748_add_remember_created_at_to_users.rb | 7 +++++++ db/openneo_id_schema.rb | 3 ++- 4 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 db/openneo_id_migrate/20230807005748_add_remember_created_at_to_users.rb diff --git a/app/models/auth_user.rb b/app/models/auth_user.rb index 4471728a..10fd1d50 100644 --- a/app/models/auth_user.rb +++ b/app/models/auth_user.rb @@ -1,7 +1,8 @@ class AuthUser < AuthRecord self.table_name = 'users' - devise :database_authenticatable, :encryptable, :registerable, :validatable + devise :database_authenticatable, :encryptable, :registerable, :validatable, + :rememberable # devise :database_authenticatable, :lockable, :registerable, :recoverable, # :trackable, :validatable diff --git a/config/database.yml b/config/database.yml index 9288fcb7..c17385f8 100644 --- a/config/database.yml +++ b/config/database.yml @@ -16,6 +16,7 @@ development: pool: 2 variables: sql_mode: TRADITIONAL + migrations_paths: db/openneo_id_migrate production: primary: @@ -27,3 +28,4 @@ production: url: <%= ENV['DATABASE_URL_OPENNEO_ID'] %> variables: sql_mode: TRADITIONAL + migrations_paths: db/openneo_id_migrate diff --git a/db/openneo_id_migrate/20230807005748_add_remember_created_at_to_users.rb b/db/openneo_id_migrate/20230807005748_add_remember_created_at_to_users.rb new file mode 100644 index 00000000..ff9ae648 --- /dev/null +++ b/db/openneo_id_migrate/20230807005748_add_remember_created_at_to_users.rb @@ -0,0 +1,7 @@ +class AddRememberCreatedAtToUsers < ActiveRecord::Migration[7.0] + def change + change_table :users do |t| + t.datetime :remember_created_at + end + end +end diff --git a/db/openneo_id_schema.rb b/db/openneo_id_schema.rb index 9395cecc..4858dbce 100644 --- a/db/openneo_id_schema.rb +++ b/db/openneo_id_schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 0) do +ActiveRecord::Schema[7.0].define(version: 2023_08_07_005748) do create_table "users", id: { type: :integer, unsigned: true }, charset: "utf8", force: :cascade do |t| t.string "name", limit: 20, null: false t.string "encrypted_password", limit: 64, null: false @@ -28,6 +28,7 @@ ActiveRecord::Schema[7.0].define(version: 0) do t.datetime "created_at", precision: nil t.datetime "updated_at", precision: nil t.datetime "reset_password_sent_at", precision: nil + t.datetime "remember_created_at" t.index ["email"], name: "index_users_on_email", unique: true 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