Force admin to change password after first sign-in

This commit is contained in:
Dmitriy Zaporozhets 2013-06-13 20:06:33 +03:00
parent 94be732026
commit fbf6989903
3 changed files with 8 additions and 4 deletions

View File

@ -159,7 +159,7 @@ class ApplicationController < ActionController::Base
end
def check_password_expiration
if current_user.password_expires_at && current_user.password_expires_at < Time.now
if current_user && current_user.password_expires_at && current_user.password_expires_at < Time.now
redirect_to new_profile_password_path and return
end
end

View File

@ -42,8 +42,11 @@ class User < ActiveRecord::Base
attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username,
:skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password,
:extern_uid, :provider, as: [:default, :admin]
attr_accessible :projects_limit, :can_create_team, :can_create_group, as: :admin
:extern_uid, :provider, :password_expires_at,
as: [:default, :admin]
attr_accessible :projects_limit, :can_create_team, :can_create_group,
as: :admin
attr_accessor :force_random_password

View File

@ -3,7 +3,8 @@ admin = User.create(
name: "Administrator",
username: 'root',
password: "5iveL!fe",
password_confirmation: "5iveL!fe"
password_confirmation: "5iveL!fe",
password_expires_at: Time.now
)
admin.projects_limit = 10000