Browse Source

inactive admins by default

pull/1/head
Claudius Nicolae 12 years ago
parent
commit
33c1b1d4ad
  1. 7
      app/assets/stylesheets/pages/home.css.scss
  2. 11
      app/models/admin.rb
  3. 10
      app/models/user.rb
  4. 2
      config/locales/devise.en.yml
  5. 9
      db/migrate/20130305074635_add_active_to_admins_and_users.rb

7
app/assets/stylesheets/pages/home.css.scss

@ -15,8 +15,7 @@
} }
.page-home-header { .page-home-header {
@include background(image-url("page-home-incentives.png"), @include background(radial-gradient(color-stops(#fff, #c1f1ff), bottom));
radial-gradient(color-stops(#fff, #c1f1ff), bottom));
border-bottom: 1px solid #B9DCFF; border-bottom: 1px solid #B9DCFF;
.page-header { .page-header {
small { small {
@ -69,3 +68,7 @@
} }
} }
} }
.public .alert {
margin-bottom: 0;
}

11
app/models/admin.rb

@ -8,4 +8,15 @@ class Admin < ActiveRecord::Base
# Setup accessible (or protected) attributes for your model # Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me attr_accessible :email, :password, :password_confirmation, :remember_me
# attr_accessible :title, :body # attr_accessible :title, :body
# Called by Devise to see if an user can currently be signed in
def active_for_authentication?
active? && super
end
# Called by Devise to get the proper error message when an user cannot be signed in
def inactive_message
!active? ? :deactivated : super
end
end end

10
app/models/user.rb

@ -37,6 +37,16 @@ class User < ActiveRecord::Base
domains.count >= Settings.max_domains_per_user.to_i domains.count >= Settings.max_domains_per_user.to_i
end end
# Called by Devise to see if an user can currently be signed in
def active_for_authentication?
active? && super
end
# Called by Devise to get the proper error message when an user cannot be signed in
def inactive_message
!active? ? :deactivated : super
end
delegate :can?, :cannot?, :to => :ability delegate :can?, :cannot?, :to => :ability
def ability(options = {:reload => false}) def ability(options = {:reload => false})

2
config/locales/devise.en.yml

@ -21,6 +21,7 @@ en:
invalid_token: 'Invalid authentication token.' invalid_token: 'Invalid authentication token.'
timeout: 'Your session expired, please sign in again to continue.' timeout: 'Your session expired, please sign in again to continue.'
inactive: 'Your account was not activated yet.' inactive: 'Your account was not activated yet.'
deactivated: 'Account locked.'
sessions: sessions:
# signed_in: 'Signed in successfully.' # signed_in: 'Signed in successfully.'
signed_in: '' signed_in: ''
@ -38,6 +39,7 @@ en:
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.' signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.' signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.' signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
signed_up_but_deactivated: 'You have signed up successfully. However, we could not sign you in because your account is deactivated.'
unlocks: unlocks:
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.' send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
unlocked: 'Your account was successfully unlocked. You are now signed in.' unlocked: 'Your account was successfully unlocked. You are now signed in.'

9
db/migrate/20130305074635_add_active_to_admins_and_users.rb

@ -0,0 +1,9 @@
class AddActiveToAdminsAndUsers < ActiveRecord::Migration
def change
add_column :admins, :active, :boolean, default: false
admin = Admin.where(email: 'admin@entrydns.net').first
admin.update_attribute(active, true) if admin
add_column :users, :active, :boolean, default: true
end
end
Loading…
Cancel
Save