Changeset 282

Show
Ignore:
Timestamp:
02/23/06 08:06:03 (3 years ago)
Author:
snowblink
Message:

Reverted release branch rb_1.0 to match rel_1.0.0

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • login_engine/branches/rb_1.0/README

    r201 r282  
    1515= Installation 
    1616 
    17 Installing the Login Engine is fairly simple. You can use either Rails' own built in plugin manager (since Engines are still plugins), or SVN itself if you are happier with that. 
    18  
    19 === <tt>script/plugin</tt> 
    20  
    21   $ ruby script/plugin discover 
    22   $ ruby script/plugin install engines 
    23   $ ruby script/plugin install login_engine 
    24  
    25 === SVN 
    26  
    27   $ cd your_app_directory 
    28   % svn co http://opensvn.csie.org/rails_engines/plugins/engines 
    29   % svn co http://opensvn.csie.org/rails_engines/plugins/login_engine 
    30  
     17Installing the Login Engine is fairly simple. You'll probably need to accept the SSL certificate here for the OpenSVN servers. For example: 
     18    $ script/plugin install login_engine 
     19  or 
     20    % svn co https://opensvn.csie.org/rails_engines/plugins/login_engine <MY_RAILS_APP>/vendor/plugins/login_engine 
     21 
     22There are a few configuration steps that you'll need to take to get everything running smoothly. Listed below are the changes to your application you will need to make. 
    3123 
    3224=== Setup your Rails application 
    33  
    34 There are a few configuration steps that you'll need to take to get everything running smoothly. Listed below are the changes to your application you will need to make. 
    3525 
    3626Edit your <tt>database.yml</tt>, most importantly! You might also want to move <tt>public/index.html</tt> out of the way, and set up some default routes in <tt>config/routes.rb</tt>. 
     
    228218                    verified by email. This overrides the +user_email_notification+ flag. 
    229219                    Defaults to true. 
    230 +login_redirect+:: Determines how redirection will be done on login. This configuration option must  
    231                    have one of three values:  
    232                    <tt>:back</tt> will redirect back, or use the default value in <tt>:default_home</tt> 
    233                    if no information about the previous URL is available.  
    234                    <tt>:stored</tt> will redirect to the stored location, or the default value in  
    235                    <tt>:default_home</tt>. This is the default if no option is given. 
    236                    <tt>:default</tt> always redirects to the value of <tt>:default_home</tt>.  
    237 +default_home+:: Determines the target of the login redirection when back is not possible, or there are no  
    238                  stored values.  This must be a Hash of options or String, as used in +url_for+.  
     220 
    239221== Overriding controllers and views 
    240222 
  • login_engine/branches/rb_1.0/app/controllers/user_controller.rb

    r246 r282  
    1717  # trying to access. If not, they will be sent to "/user/home". 
    1818  def login 
    19     # get the previous page before any redirection happened here 
    20     if request.get? and :back == LoginEngine.config(:login_redirect) 
    21       session['back-to'] = request.env['HTTP_REFERER'] 
    22     end 
    23                 
    2419    return if generate_blank 
    2520    @user = User.new(params[:user]) 
     
    2823      session[:user].save 
    2924      flash[:notice] = 'Login successful' 
    30  
    31       case LoginEngine.config(:login_redirect)  
    32             when :back 
    33               # we have stored the 'back' link, so we should send them to whatever page they 
    34               # were at *before* they clicked 'login'. 
    35               redirect_to session['back-to'] || LoginEngine.default_home  
    36               session['back-to'] = nil  
    37              
    38             when :default  
    39               # whenever someone logs in, we always want to send them to the homepage 
    40               redirect_to LoginEngine.default_home  
    41              
    42             else  
    43               # they got sent to login because of an unauthorised action, so we should have 
    44               # the location stored anyway. 
    45               redirect_to_stored_or_default 
    46             end  
    47  
     25      redirect_to_stored_or_default :action => 'home' 
    4826    else 
    4927      @login = params[:user][:login] 
     
    209187          end 
    210188        else 
    211           destroy(user) 
     189          destroy(@user) 
    212190        end 
    213191        return true 
  • login_engine/branches/rb_1.0/app/helpers/user_helper.rb

    r269 r282  
    3030<<-EOL 
    3131        <tr class="two_columns"> 
    32           <td class="prompt"><label for="#{form_name}_#{field_name}">#{prompt}:</label></td> 
     32          <td class="prompt"><label>#{prompt}:</label></td> 
    3333          <td class="value">#{field}</td> 
    3434        </tr> 
     
    3636      else 
    3737<<-EOL 
    38         <tr><td class="prompt"><label for="#{form_name}_#{field_name}">#{prompt}:</label></td></tr> 
     38        <tr><td class="prompt"><label>#{prompt}:</label></td></tr> 
    3939        <tr><td class="value">#{field}</td></tr> 
    4040        EOL 
  • login_engine/branches/rb_1.0/app/views/user/edit.rhtml

    r244 r282  
    44  <%= error_messages_for 'user' %> 
    55 
    6   <%= start_form_tag :action => 'edit' %> 
    7     <%= render_partial 'edit', :user => @user, :submit => true %> 
    8   <%= end_form_tag %> 
    9   <br/> 
    10   <%= start_form_tag :action => 'change_password' %> 
    11     <%= hidden_field_tag "back_to", "edit" %> 
    12     <%= render_partial 'password', :submit => true %> 
    13   <%= end_form_tag %> 
     6    <%= start_form_tag :action => 'edit' %> 
     7      <%= render_partial 'edit', :user => @user, :submit => true %> 
     8    <%= end_form_tag %> 
     9    <br/> 
     10    <%= start_form_tag :action => 'change_password' %> 
     11      <%= hidden_field_tag "back_to", "edit" %> 
     12      <%= render_partial 'password', :submit => true %> 
     13    <%= end_form_tag %> 
    1414 
    15   <%= start_form_tag :action => 'delete' %> 
    16     <div class="user_delete"> 
    17       <%= hidden_field 'user', 'form', :value => 'delete' %> 
     15    <%= start_form_tag :action => 'delete' %> 
     16      <div class="user_delete"> 
     17        <%= hidden_field 'user', 'form', :value => 'delete' %> 
    1818 
    19       <%= form_input :submit_button, 'Delete Account' %> 
    20     </div> 
    21   <%= end_form_tag %> 
     19        <%= form_input :submit_button, 'Delete Account' %> 
     20      </div> 
     21    <%= end_form_tag %> 
     22  </div> 
    2223</div> 
  • login_engine/branches/rb_1.0/db/migrate/001_initial_schema.rb

    r268 r282  
    11class InitialSchema < ActiveRecord::Migration 
    22  def self.up 
    3     # NOTE that we don't need to wrap the table name here, since Migrations 
    4     # will do it whether we want it to or not. 
    53    create_table LoginEngine.config(:user_table), :force => true do |t| 
    64      t.column "login", :string, :limit => 80, :default => "", :null => false 
  • login_engine/branches/rb_1.0/init_engine.rb

    r268 r282  
    33require 'login_engine' 
    44 
    5 module ::LoginEngine::Version 
    6   Major = 1 # change implies compatibility breaking with previous versions 
    7   Minor = 0 # change implies backwards-compatible change to API 
    8   Release = 1 # incremented with bug-fixes, updates, etc. 
    9 end 
     5# TODO: why do I have to include these here, when including them in login_engine.rb should be sufficient? 
     6require 'authenticated_user' 
     7require 'authenticated_system' 
    108 
    11 Engines.current.version = LoginEngine::Version 
    12  
    13 # send the helpers and modules automatically....? 
    149#ApplicationController.send(:include, LoginEngine) 
    1510#ApplicationHelper.send(:include, LoginEngine) 
  • login_engine/branches/rb_1.0/lib/login_engine.rb

    r268 r282  
    5252    config :user_table, "user" 
    5353  end 
    54    
     54 
    5555  # controls whether or not email is used 
    5656  config :use_email_notification, true 
     
    6060  config :confirm_account, true 
    6161 
    62   # Sets the default URL to send users to when they have logged in 
    63   config :login_redirect, :stored 
    64  
    65   # The default 'home' location 
    66   config :default_home, {:controller => 'user', :action => 'home'} 
    67    
    6862end 
  • login_engine/branches/rb_1.0/lib/login_engine/authenticated_system.rb

    r201 r282  
    7474 
    7575    # move to the last store_location call or to the passed default one 
    76     def redirect_to_stored_or_default(default=default_home
     76    def redirect_to_stored_or_default(default=nil
    7777      if session['return-to'].nil? 
    7878        redirect_to default 
     
    8383    end 
    8484 
    85     def redirect_back_or_default(default=default_home
     85    def redirect_back_or_default(default=nil
    8686      if request.env["HTTP_REFERER"].nil? 
    8787        redirect_to default 
     
    8989        redirect_to(request.env["HTTP_REFERER"]) # same as redirect_to :back 
    9090      end 
    91     end 
    92  
    93     def default_home 
    94       case LoginEngine.config(:default_home)  
    95       when Hash  
    96         url_for LoginEngine.config(:default_home)  
    97       when String  
    98         LoginEngine.config(:default_home)  
    99       else  
    100         # last ditch attempt - this would only happen if the user has 
    101         # set the config value to something REALLY weird. 
    102         url_for :controller => 'user', :action => 'home'  
    103       end      
    10491    end 
    10592 
  • login_engine/branches/rb_1.0/lib/login_engine/authenticated_user.rb

    r268 r282  
    99      base.class_eval do 
    1010 
    11         # use the table name given. NOTE that this will wrap the table name 
    12         # using the set prefix/suffix. TODO: this behaviour isn't ideal, but it 
    13         # is necessary since migrations will ALWAYS wrap using the prefix/suffix. 
    14         # To explicitly and COMPLETELY set a unique table name, create a version 
    15         # of the User model in your own application and use set_table_name there. 
    16         set_table_name wrapped_table_name(LoginEngine.config(:user_table)) 
     11        # use the table name given 
     12        set_table_name LoginEngine.config(:user_table) 
    1713 
    1814        attr_accessor :new_password 
    1915       
     16        validates_presence_of :login 
    2017        validates_length_of :login, :within => 3..40 
    2118        validates_uniqueness_of :login 
    2219        validates_uniqueness_of :email 
    2320 
     21        validates_presence_of :password, :if => :validate_password? 
    2422        validates_confirmation_of :password, :if => :validate_password? 
    2523        validates_length_of :password, { :minimum => 5, :if => :validate_password? } 
  • login_engine/branches/rb_1.0/test/functional/user_controller_test.rb

    r268 r282  
    1010  # load the fixture into the developer-specified table using the custom 
    1111  # 'fixture' method. 
    12   fixture :users, :class_name => "User", 
    13           :table_name => ActiveRecord::Base.wrapped_table_name(LoginEngine.config(:user_table)) 
     12  fixture :users, :table_name => LoginEngine.config(:user_table), :class_name => "User" 
    1413   
    1514  def setup 
  • login_engine/branches/rb_1.0/test/unit/user_test.rb

    r268 r282  
    33 
    44  # load the fixture into the developer-specified table using the custom 
    5   # 'fixture' method. Note that it is necessary at the moment to explicitly 
    6   # wrap the table name. TODO: determine the table name from the Class object. 
    7   fixture :users, :class_name => "User",  
    8           :table_name => ActiveRecord::Base.wrapped_table_name(LoginEngine.config(:user_table)) 
     5  # 'fixture' method. 
     6  fixture :users, :table_name => LoginEngine.config(:user_table), :class_name => "User" 
    97  
    108  def setup