Commit fbf69899032ffd5e74e401aae7c94852a0722e92
1 parent
94be7320
Exists in
master
and in
4 other branches
Force admin to change password after first sign-in
Showing
3 changed files
with
8 additions
and
4 deletions
Show diff stats
app/controllers/application_controller.rb
| @@ -159,7 +159,7 @@ class ApplicationController < ActionController::Base | @@ -159,7 +159,7 @@ class ApplicationController < 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 && current_user.password_expires_at < Time.now | 162 | + if current_user && 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 |
app/models/user.rb
| @@ -42,8 +42,11 @@ class User < ActiveRecord::Base | @@ -42,8 +42,11 @@ class User < ActiveRecord::Base | ||
| 42 | 42 | ||
| 43 | attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username, | 43 | attr_accessible :email, :password, :password_confirmation, :remember_me, :bio, :name, :username, |
| 44 | :skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password, | 44 | :skype, :linkedin, :twitter, :color_scheme_id, :theme_id, :force_random_password, |
| 45 | - :extern_uid, :provider, as: [:default, :admin] | ||
| 46 | - attr_accessible :projects_limit, :can_create_team, :can_create_group, as: :admin | 45 | + :extern_uid, :provider, :password_expires_at, |
| 46 | + as: [:default, :admin] | ||
| 47 | + | ||
| 48 | + attr_accessible :projects_limit, :can_create_team, :can_create_group, | ||
| 49 | + as: :admin | ||
| 47 | 50 | ||
| 48 | attr_accessor :force_random_password | 51 | attr_accessor :force_random_password |
| 49 | 52 |
db/fixtures/production/001_admin.rb
| @@ -3,7 +3,8 @@ admin = User.create( | @@ -3,7 +3,8 @@ admin = User.create( | ||
| 3 | name: "Administrator", | 3 | name: "Administrator", |
| 4 | username: 'root', | 4 | username: 'root', |
| 5 | password: "5iveL!fe", | 5 | password: "5iveL!fe", |
| 6 | - password_confirmation: "5iveL!fe" | 6 | + password_confirmation: "5iveL!fe", |
| 7 | + password_expires_at: Time.now | ||
| 7 | ) | 8 | ) |
| 8 | 9 | ||
| 9 | admin.projects_limit = 10000 | 10 | admin.projects_limit = 10000 |