Module: AccountEngine

Includes:
Helper
Defined in:
lib/account_engine/user_account.rb,
lib/account_engine.rb,
lib/account_engine/helper.rb,
lib/account_engine/controller.rb,
lib/account_engine/configuration.rb,
lib/account_engine/user_account/class_methods.rb

Overview

Configuration

Defined Under Namespace

Modules: Controller, Helper, Support, UserAccount Classes: SystemProtectionError

Constant Summary collapse

@@users_table =
"user"
@@roles_table =
"role"
@@permissions_table =
"permission"
@@generate_password =

Generate random passwords

true
@@site_email =

Source address for user emails

'root@localhost'
@@admin_email =

Destination email for system errors

"root@localhost"
@@app_url =

Sent in emails to users

'http://localhost:3000/'
@@app_name =

Sent in emails to users

'My Application'
@@validate_email =

Whether the model will enforce email validation

true
@@email_charset =

Email charset

'utf-8'
@@security_token_life_hours =

Security token lifetime in hours

48
@@registration =

Registrations are open to the public

:closed
@@use_email_notification =

controls whether or not email is used

true
@@confirm_account =

Controls whether accounts must be confirmed after signing up ONLY if this and use_email_notification are both true

false
@@guest_role_name =

The names of the Guest and User roles The Guest role is automatically assigned to any visitor who is not logged in

"Guest"
@@user_role_name =

The User role is given to every user

"User"
@@admin_role_name =

The details for the Admin user and role

"Administrator"
@@admin_login =
"admin"
@@admin_password =
"test123"
@@login_page =

The controller/action

{:controller => 'account', :action => 'login'}
@@logout_page =
{:controller => 'account', :action => 'logout'}
@@stealth =

If this is set to true, authorization failure messages won’t volunteer any extra information, and missing actions will not be flagged as such.

false

Class Method Summary collapse

Methods included from Helper

#authorized?, #link_if_authorized, #link_to_user

Methods included from Support

#current_user, #user?

Class Method Details

.allow_registration?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/account_engine/configuration.rb', line 42

def self.allow_registration?
  return (@@registration == :open ? true : false)
end

.check_system_rolesObject

This method will check the Roles in the database against to ensure that there is only ONE omnipotent role.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/account_engine.rb', line 31

def self.check_system_roles
  begin
    if Role.count() > 0
      begin
        omnipotent_roles = Role.find_all_by_omnipotent(true)
        if omnipotent_roles && omnipotent_roles.length != 1
          @warning = "WARNING: You have more than one omnipotent role: " + 
                     omnipotent_roles.collect { |r| r.name }.join(", ")
        elsif omnipotent_roles == nil
          @warning = "WARNING: You have no omnipotent roles. Please re-run the bootstrap rake task."
        end
      rescue
        @warning = "WARNING: Could not check integrity of system roles. Please check your data."
      end
    else
      raise "skip error" # this will be caught below
    end
  rescue # either Roles.count() == 0, or the Roles table doesn't even exist yet.
    @warning = "Skipping integrity check. You have no system roles set up; once your " +
               "database tables are set up, run rake bootstrap to create the basic roles."
  end
  
  if @warning != nil
    RAILS_DEFAULT_LOGGER.warn @warning
    puts @warning
  end
end

.permissions_roles_tableObject



38
39
40
# File 'lib/account_engine/configuration.rb', line 38

def self.permissions_roles_table
  "#{AccountEngine.permissions_table}_#{AccountEngine.roles_table}"
end

.registration=(r) ⇒ Object



9
10
11
12
13
# File 'lib/account_engine/configuration.rb', line 9

def self.registration=(r)
  if [:open, :closed].include? r
    @@registration = r
  end
end

.users_roles_tableObject

Join tables for users <-> roles, and roles <-> permissions



34
35
36
# File 'lib/account_engine/configuration.rb', line 34

def self.users_roles_table
  "#{AccountEngine.users_table}_#{AccountEngine.roles_table}"
end