Commit 94be73202617a5b0886c348ffbaf08947ecf8b45

Authored by Dmitriy Zaporozhets
1 parent 5b407802

Add password_expires_at to users table

app/controllers/application_controller.rb
1 class ApplicationController < ActionController::Base 1 class ApplicationController < ActionController::Base
2 before_filter :authenticate_user! 2 before_filter :authenticate_user!
3 before_filter :reject_blocked! 3 before_filter :reject_blocked!
4 - before_filter :check_password_expiration! 4 + before_filter :check_password_expiration
5 before_filter :set_current_user_for_thread 5 before_filter :set_current_user_for_thread
6 before_filter :add_abilities 6 before_filter :add_abilities
7 before_filter :dev_tools if Rails.env == 'development' 7 before_filter :dev_tools if Rails.env == 'development'
@@ -159,7 +159,7 @@ class ApplicationController &lt; ActionController::Base @@ -159,7 +159,7 @@ class ApplicationController &lt; ActionController::Base
159 end 159 end
160 160
161 def check_password_expiration 161 def check_password_expiration
162 - if current_user.password_expires_at < Time.now 162 + if current_user.password_expires_at && current_user.password_expires_at < Time.now
163 redirect_to new_profile_password_path and return 163 redirect_to new_profile_password_path and return
164 end 164 end
165 end 165 end
db/migrate/20130613165816_add_password_expires_at_to_users.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +class AddPasswordExpiresAtToUsers < ActiveRecord::Migration
  2 + def change
  3 + add_column :users, :password_expires_at, :datetime
  4 + end
  5 +end
@@ -11,7 +11,7 @@ @@ -11,7 +11,7 @@
11 # 11 #
12 # It's strongly recommended to check this file into your version control system. 12 # It's strongly recommended to check this file into your version control system.
13 13
14 -ActiveRecord::Schema.define(:version => 20130522141856) do 14 +ActiveRecord::Schema.define(:version => 20130613165816) do
15 15
16 create_table "deploy_keys_projects", :force => true do |t| 16 create_table "deploy_keys_projects", :force => true do |t|
17 t.integer "deploy_key_id", :null => false 17 t.integer "deploy_key_id", :null => false
@@ -292,6 +292,7 @@ ActiveRecord::Schema.define(:version =&gt; 20130522141856) do @@ -292,6 +292,7 @@ ActiveRecord::Schema.define(:version =&gt; 20130522141856) do
292 t.string "state" 292 t.string "state"
293 t.integer "color_scheme_id", :default => 1, :null => false 293 t.integer "color_scheme_id", :default => 1, :null => false
294 t.integer "notification_level", :default => 1, :null => false 294 t.integer "notification_level", :default => 1, :null => false
  295 + t.datetime "password_expires_at"
295 end 296 end
296 297
297 add_index "users", ["admin"], :name => "index_users_on_admin" 298 add_index "users", ["admin"], :name => "index_users_on_admin"