Class: LdapAuthGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/ldap_auth/ldap_auth_generator.rb

Instance Method Summary collapse

Instance Method Details

#add_before_filterObject



11
12
13
14
15
# File 'lib/generators/ldap_auth/ldap_auth_generator.rb', line 11

def add_before_filter
  inject_into_class "app/controllers/application_controller.rb", ApplicationController do
   "  before_filter :require_ldap_auth, :except => [:ldap_login, :persist_ldap_login, :ldap_logout]\n"
  end
end

#add_routesObject



17
18
19
20
21
# File 'lib/generators/ldap_auth/ldap_auth_generator.rb', line 17

def add_routes
  route "get '/ldap_login' => 'LdapLogins#ldap_login', :as => :ldap_login"
  route "post '/ldap_login' => 'LdapLogins#persist_ldap_login', :as => :persist_ldap_login"
  route "post '/ldap_logout' => 'LdapLogins#ldap_logout', :as => :ldap_logout"
end

#create_controllerObject



23
24
25
# File 'lib/generators/ldap_auth/ldap_auth_generator.rb', line 23

def create_controller
  copy_file "ldap_logins_controller.rb", "app/controllers/ldap_logins_controller.rb"
end

#create_initializerObject



6
7
8
9
# File 'lib/generators/ldap_auth/ldap_auth_generator.rb', line 6

def create_initializer
  LdapRails.configure :host => ldap_host
  template "ldap_auth.rb.erb", "config/initializers/ldap_auth.rb"
end

#create_viewsObject



27
28
29
# File 'lib/generators/ldap_auth/ldap_auth_generator.rb', line 27

def create_views
  copy_file "ldap_login.html.erb", "app/views/ldap_logins/ldap_login.html.erb"
end

#instructionsObject



31
32
33
# File 'lib/generators/ldap_auth/ldap_auth_generator.rb', line 31

def instructions
  readme "README"
end