Changeset 446

Show
Ignore:
Timestamp:
08/24/06 02:43:25 (2 years ago)
Author:
snowblink
Message:

Merged LoginEngine? rb_1.0 changes r362:443 into trunk.
Corresponds to tagged release LoginEngine? 1.0.3

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • login_engine/trunk/CHANGELOG

    r362 r446  
    1 = v1.1.0 
    2  *  Added 'full_name' method to user object 
    3  *  Added 'for' attributes to form_helper labels (Ticket #82) 
    4  *  Default table names now respect any set prefix/suffix from ActiveRecord (Ticket #67) 
    5  *  Removed errant closing DIV tag in views/user/edit.rhtml (Ticket #68) 
    6  *  do_delete_user() should delete the user given as a parameter, not @user (Ticket #65) 
     1= v1.0.3 (2006-08-22) 
     2* Ticket #173 (kevin.olbrich@gmail.com) The login_required method now returns false if the user cannot be authenticated 
     3* Ticket #192 (Carl Johnson) Added a 'full_name' method to the User object, and updated README to reflect this 
     4* Ticket #200 (segabor@gmail.com) Session is reset after logout 
     5* Ticket #201 (snowblink@gmail.com) Tidied up views to generate valid HTML 4.0.1 Transitional 
     6* Ticket #207 (snowblink@gmail.com) LoginEngine.config(:password_minimum) can be set and used as other config options. See README 
    77 
    8 = v1.0.1 
    9  * Added CHANGELOG 
    10  * Changed wording for when password forgotten to 'reset', rather than 'retrieve'. (snowblink@gmail.com) 
    11  * Fixed new location of engines testing extensions. (lazyatom@gmail.com) 
    12  * Removed schema.db from Login Engine; migrations should be used instead. (snowblink@gmail.com) 
    13  * Updated User Controller tests to parse the user_id and email out of the URL in the email body. (snowblink@gmail.com) 
    14  * Ticket #89 (lazyatom@gmail.com) User creation halts the after_save callback chain. 
    15  * Ticket #97 (dcorbin@machturtle.com) The forgotten_password view generates invalid HTML 
    16  * Ticket #112 (segabor@gmail.com) Authentication system will break even on successful login 
    17  * Added simple email validation to the User model. (snowblink@gmail.com) 
    18    This should also take care of the unit test failures detailed in Ticket #114 (morris@wolfman.com) 
    19  * Ticket #118 (augustz@augustz.com) SVN source for login_engine not found 
    20  * Ticket #119 (Goynang) Unit tests for engines fail after default install 
    21  * Ticket #126 (lazyatom@gmail.com) Add install.rb to login engine 
     8= v1.0.2 (2006-06-03) 
     9* Added version 
     10* Removed errant requires no longer needed (murray.steele@gmail.com, Ticket #156, Ticket #157, Ticket #158) 
     11* Removed documentation/rake tasks that refer the schema.rb (Ticket #155) 
     12* Verified cannot be assigned via URL parameters. If more security is required, users should override the signup action itself (Ticket #169) 
     13* Minor view/flash message cleanup 
     14* Authentication by token now respects primary key prefixes (Ticket #140) 
     15 
     16= v1.0.1 (2006-04-10) 
     17* Added CHANGELOG 
     18* Changed wording for when password forgotten to 'reset', rather than 'retrieve'. (snowblink@gmail.com) 
     19* Fixed new location of engines testing extensions. (lazyatom@gmail.com) 
     20* Removed schema.db from Login Engine; migrations should be used instead. (snowblink@gmail.com) 
     21* Updated User Controller tests to parse the user_id and email out of the URL in the email body. (snowblink@gmail.com) 
     22* Ticket #89 (lazyatom@gmail.com) User creation halts the after_save callback chain. 
     23* Ticket #97 (dcorbin@machturtle.com) The forgotten_password view generates invalid HTML 
     24* Ticket #112 (segabor@gmail.com) Authentication system will break even on successful login 
     25* Added simple email validation to the User model. (snowblink@gmail.com) 
     26  This should also take care of the unit test failures detailed in Ticket #114 (morris@wolfman.com) 
     27* Ticket #118 (augustz@augustz.com) SVN source for login_engine not found 
     28* Ticket #119 (Goynang) Unit tests for engines fail after default install 
     29* Ticket #126 (lazyatom@gmail.com) Add install.rb to login engine 
  • login_engine/trunk/README

    r362 r446  
    102102=== Create the DB schema 
    103103 
    104 After you have done the modifications the the ApplicationController and its helper, you can import the user model into the database. An ActiveRecord schema.rb file is provided in login_engine/db/schema.rb, along with migration information in login_engine/db/migrate/.  
     104After you have done the modifications the the ApplicationController and its helper, you can import the user model into the database. Migration information in login_engine/db/migrate/.  
    105105 
    106106You *MUST* check that these files aren't going to interfere with anything in your application.  
     
    117117...to the LoginEngine configuration in <tt>environment.rb</tt>. Then run from the root of your project: 
    118118 
    119   rake engine_migrate ENGINE=login 
     119  rake db:migrate:engines ENGINE=login 
    120120 
    121121to import the schema into your database. 
     
    238238+default_home+:: Determines the target of the login redirection when back is not possible, or there are no  
    239239                 stored values.  This must be a Hash of options or String, as used in +url_for+.  
     240+password_minimum+:: Set your minimum password length. 
     241                     Defaults to 5. 
     242 
    240243== Overriding controllers and views 
    241244 
     
    251254  A: You can get the user object from the session using session[:user] 
    252255     Example:  
    253        Welcome <%= session[:user].name %> 
     256       Welcome <%= session[:user].full_name %> 
    254257 
    255258    You can also use the 'current_user' method provided by UserHelper: 
    256259    Example: 
    257       Welcome <%= current_user.name %> 
     260      Welcome <%= current_user.full_name %> 
    258261 
    259262 
  • login_engine/trunk/app/controllers/user_controller.rb

    r298 r446  
    5757    return if generate_blank 
    5858    params[:user].delete('form') 
     59    params[:user].delete('verified') # you CANNOT pass this as part of the request 
    5960    @user = User.new(params[:user]) 
    6061    begin 
     
    6768          key = @user.generate_security_token 
    6869          url = url_for(:action => 'home', :user_id => @user.id, :key => key) 
    69           flash[:notice] = 'Signup successful! Please log in.
     70          flash[:notice] = 'Signup successful!
    7071          if LoginEngine.config(:use_email_notification) and LoginEngine.config(:confirm_account) 
    7172            UserNotify.deliver_signup(@user, params[:user][:password], url) 
    7273            flash[:notice] << ' Please check your registered email account to verify your account registration and continue with the login.' 
     74          else 
     75            flash[:notice] << ' Please log in.' 
    7376          end 
    7477          redirect_to :action => 'login' 
     
    8588  def logout 
    8689    session[:user] = nil 
     90    reset_session 
    8791    redirect_to :action => 'login' 
    8892  end 
  • login_engine/trunk/app/views/user/_edit.rhtml

    r50 r446  
    33    <%= form_input changeable(user, "firstname"), "First Name", "firstname" %> 
    44    <%= form_input changeable(user, "lastname"), "Last Name","lastname" %> 
    5     <%= form_input changeable(user, "login"), "Login ID", "login", :size => 30 %><br/
     5    <%= form_input changeable(user, "login"), "Login ID", "login" %
    66    <%= form_input changeable(user, "email"), "Email", "email" %> 
    77    <% if submit %> 
  • login_engine/trunk/app/views/user/edit.rhtml

    r281 r446  
    1616    <div class="user_delete"> 
    1717      <%= hidden_field 'user', 'form', :value => 'delete' %> 
    18  
    19       <%= form_input :submit_button, 'Delete Account' %> 
     18      <%= submit_tag "Delete Account", :name => 'submit' %> 
    2019    </div> 
    2120  <%= end_form_tag %> 
  • login_engine/trunk/app/views/user/forgot_password.rhtml

    r362 r446  
    1111 
    1212      <div class="button-bar"> 
    13         <%= submit_tag 'Submit request' %> 
     13        <%= submit_tag 'Reset Password' %> 
    1414        <%= link_to 'Cancel', :action => 'login' %> 
    1515      </div> 
  • login_engine/trunk/app/views/user/login.rhtml

    r50 r446  
    55    <%= start_form_tag :action => 'login'  %> 
    66      <table> 
    7         <%= form_input :text_field, "Login ID", "login", :size => 30 %><br/> 
    8         <%= form_input :password_field, "Password", "password", :size => 30 %><br/> 
     7        <%= form_input :text_field, "Login ID", "login", :size => 30 %> 
     8        <%= form_input :password_field, "Password", "password", :size => 30 %> 
    99      </table> 
    1010 
     
    1212        <%= submit_tag 'Login' %> 
    1313        <%= link_to 'Register for an account', :action => 'signup' %> | 
    14         <%= link_to 'Forgot my password', :action => 'forgot_password' %>      </div> 
     14        <%= link_to 'Forgot my password', :action => 'forgot_password' %> 
     15      </div> 
    1516    <%= end_form_tag %> 
    1617  </div> 
  • login_engine/trunk/init_engine.rb

    r281 r446  
    66  Major = 1 # change implies compatibility breaking with previous versions 
    77  Minor = 0 # change implies backwards-compatible change to API 
    8   Release = 1 # incremented with bug-fixes, updates, etc. 
     8  Release = 3 # incremented with bug-fixes, updates, etc. 
    99end 
    1010 
    1111Engines.current.version = LoginEngine::Version 
    12  
    13 # send the helpers and modules automatically....? 
    14 #ApplicationController.send(:include, LoginEngine) 
    15 #ApplicationHelper.send(:include, LoginEngine) 
  • login_engine/trunk/lib/login_engine.rb

    r281 r446  
    4545  # Default is one week 
    4646  config :delayed_delete_days, 7 
     47 
     48  # Default minimum password length 
     49  config :password_minimum, 5 
    4750   
    4851  # the table to store user information in 
  • login_engine/trunk/lib/login_engine/authenticated_system.rb

    r362 r446  
    5555      # call overwriteable reaction to unauthorized access 
    5656      access_denied 
     57       
     58      # Return false to halt the filter chain 
     59      return false 
    5760    end 
    5861 
  • login_engine/trunk/lib/login_engine/authenticated_user.rb

    r362 r446  
    2424 
    2525        validates_confirmation_of :password, :if => :validate_password? 
    26         validates_length_of :password, { :minimum => 5, :if => :validate_password? } 
     26        validates_length_of :password, { :minimum => LoginEngine.config(:password_minimum), :if => :validate_password? } 
    2727        validates_length_of :password, { :maximum => 40, :if => :validate_password? } 
    2828   
     
    4949        # Allow logins for deleted accounts, but only via this method (and 
    5050        # not the regular authenticate call) 
    51         u = find(:first, :conditions => ["id = ? AND security_token = ?", id, token]) 
     51        u = find(:first, :conditions => ["#{User.primary_key} = ? AND security_token = ?", id, token]) 
    5252        return nil if u.nil? or u.token_expired? 
    5353        return nil if false == u.update_expiry 
     
    123123    end 
    124124     
     125    def full_name 
     126      "#{self.firstname} #{self.lastname}" 
     127    end 
     128     
    125129    protected 
    126130 
  • login_engine/trunk/test/fixtures/users.yml

    r108 r446  
    44  id: 1000001 
    55  login: bob 
     6  firstname: bob 
     7  lastname: roberts 
    68  salted_password: b1de1d1d2aec05df2be6f02995537c1783f08490 # atest 
    79  salt: bf3c47e71c0bfeb6288c9b6b5e24e15256a0e407 
  • login_engine/trunk/test/functional/user_controller_test.rb

    r362 r446  
    6262    get :logout 
    6363    assert_session_has_no :user 
     64    assert_equal Hash.new, session 
    6465 
    6566  end 
  • login_engine/trunk/test/unit/user_test.rb

    r362 r446  
    113113    assert u.save 
    114114  end 
     115   
     116  def test_should_respond_to_full_name 
     117    assert_equal 'bob roberts', users(:bob).full_name 
     118  end 
     119 
     120  def test_password_too_short 
     121    assert LoginEngine::config(:password_minimum), "Password minimum not defined" 
     122    u = User.new 
     123    u.login = 'password_test' 
     124    u.email = 'bobs@email.com' 
     125    u.change_password('a'*(LoginEngine::config(:password_minimum)-1)) 
     126    assert !u.save 
     127  end 
     128 
     129  def test_password_minimum_length 
     130    u = User.new 
     131    u.login = 'password_test' 
     132    u.email = 'bobs@email.com' 
     133    u.change_password('a'*(LoginEngine::config(:password_minimum))) 
     134    assert u.save 
     135  end 
    115136 
    116137end