From 94be73202617a5b0886c348ffbaf08947ecf8b45 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 13 Jun 2013 20:01:35 +0300 Subject: [PATCH] Add password_expires_at to users table --- app/controllers/application_controller.rb | 4 ++-- db/migrate/20130613165816_add_password_expires_at_to_users.rb | 5 +++++ db/schema.rb | 3 ++- 3 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20130613165816_add_password_expires_at_to_users.rb diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 63ad8d0..edb1b78 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,7 +1,7 @@ class ApplicationController < ActionController::Base before_filter :authenticate_user! before_filter :reject_blocked! - before_filter :check_password_expiration! + before_filter :check_password_expiration before_filter :set_current_user_for_thread before_filter :add_abilities before_filter :dev_tools if Rails.env == 'development' @@ -159,7 +159,7 @@ class ApplicationController < ActionController::Base end def check_password_expiration - if current_user.password_expires_at < Time.now + if current_user.password_expires_at && current_user.password_expires_at < Time.now redirect_to new_profile_password_path and return end end diff --git a/db/migrate/20130613165816_add_password_expires_at_to_users.rb b/db/migrate/20130613165816_add_password_expires_at_to_users.rb new file mode 100644 index 0000000..3479c8e --- /dev/null +++ b/db/migrate/20130613165816_add_password_expires_at_to_users.rb @@ -0,0 +1,5 @@ +class AddPasswordExpiresAtToUsers < ActiveRecord::Migration + def change + add_column :users, :password_expires_at, :datetime + end +end diff --git a/db/schema.rb b/db/schema.rb index 21e553d..ce8c6d2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20130522141856) do +ActiveRecord::Schema.define(:version => 20130613165816) do create_table "deploy_keys_projects", :force => true do |t| t.integer "deploy_key_id", :null => false @@ -292,6 +292,7 @@ ActiveRecord::Schema.define(:version => 20130522141856) do t.string "state" t.integer "color_scheme_id", :default => 1, :null => false t.integer "notification_level", :default => 1, :null => false + t.datetime "password_expires_at" end add_index "users", ["admin"], :name => "index_users_on_admin" -- libgit2 0.21.2