Changeset 276
- Timestamp:
- 03/11/08 23:47:04 (5 months ago)
- Files:
-
- incubator/jumpstart/app/controllers/sessions_controller.rb (modified) (2 diffs)
- incubator/jumpstart/app/controllers/users_controller.rb (modified) (1 diff)
- incubator/jumpstart/app/views/layouts/application.html.erb (modified) (1 diff)
- incubator/jumpstart/app/views/sessions/new.html.erb (modified) (1 diff)
- incubator/jumpstart/app/views/users/forgot_password.html.erb (modified) (1 diff)
- incubator/jumpstart/app/views/users/new.html.erb (modified) (1 diff)
- incubator/jumpstart/app/views/welcome/index.html.erb (modified) (1 diff)
- incubator/jumpstart/config/routes.rb (modified) (1 diff)
- incubator/jumpstart/db/migrate/002_add_open_id_authentication.rb (added)
- incubator/jumpstart/db/schema.rb (modified) (1 diff)
- incubator/jumpstart/lib/authentable_entity.rb (modified) (2 diffs)
- incubator/jumpstart/public/stylesheets/application.css (added)
- incubator/jumpstart/test/functional/users_controller_test.rb (modified) (1 diff)
- incubator/jumpstart/vendor/gems/gems/ruby-openid-1.1.4/lib/openid/discovery.rb (modified) (1 diff)
- incubator/jumpstart/vendor/gems/gems/ruby-openid-1.1.4/lib/openid/service.rb (modified) (1 diff)
- incubator/jumpstart/vendor/plugins (modified) (1 prop)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
incubator/jumpstart/app/controllers/sessions_controller.rb
r214 r276 7 7 8 8 def create 9 self.current_user = User.authenticate(params[:email], params[:password]) 10 if logged_in? 11 if params[:remember_me] == "1" 12 self.current_user.remember_me 13 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } 14 end 15 redirect_back_or_default('/') 16 flash[:notice] = "Logged in successfully" 17 else 18 render :action => 'new' 9 if using_open_id? 10 open_id_authentication 11 elsif params[:email] 12 password_authentication(params[:email], params[:password]) 19 13 end 20 14 end … … 25 19 reset_session 26 20 flash[:notice] = "You have been logged out." 27 redirect_back_or_default ('/')21 redirect_back_or_default root_path 28 22 end 23 24 protected 25 26 def password_authentication(login, password) 27 self.current_user = User.authenticate(params[:email], params[:password]) 28 if logged_in? 29 if params[:remember_me] == "1" 30 self.current_user.remember_me 31 cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } 32 end 33 successful_login 34 else 35 failed_login "Invalid login or password" 36 end 37 end 38 39 def open_id_authentication 40 authenticate_with_open_id do |result, identity_url| 41 if result.successful? 42 if self.current_user = User.find_or_create_by_identity_url(identity_url) 43 successful_login 44 else 45 failed_login "Sorry, no user by that identity URL exists (#{identity_url})" 46 end 47 else 48 failed_login result.message 49 end 50 end 51 end 52 53 private 54 55 def successful_login 56 flash[:notice] = "Logged in successfully" 57 redirect_back_or_default root_path 58 end 59 60 def failed_login(message) 61 flash[:warning] = message 62 redirect_to login_path 63 end 29 64 end incubator/jumpstart/app/controllers/users_controller.rb
r271 r276 49 49 else 50 50 flash[:user] = @user 51 redirect_to edit_user_path @user51 redirect_to edit_user_path(@user) 52 52 end 53 53 end incubator/jumpstart/app/views/layouts/application.html.erb
r271 r276 4 4 <%= html_title AppConfiguration.domain %> 5 5 <%= meta_tags @meta %> 6 <%= stylesheet_link_tag 'application' %> 6 7 </head> 7 8 <body> incubator/jumpstart/app/views/sessions/new.html.erb
r271 r276 4 4 <%= page_title 'User Login' %> 5 5 6 <% form_tag session_path do -%> 7 <p> 8 <label for="email">Email</label><br/> 9 <%= text_field_tag 'email' %> 10 </p> 6 <div id="openid-login"> 7 <% form_tag session_path do -%> 8 <p> 9 <label for="openid_url">OpenID</label><br/> 10 <%= text_field_tag 'openid_url' %> 11 </p> 11 12 12 <p> 13 <label for="password">Password</label><br/> 14 <%= password_field_tag 'password' %> 15 </p> 13 <p> 14 <%= submit_tag 'Log in with OpenID' %> 15 <%= link_to 'Cancel', root_path %> 16 </p> 17 <% end -%> 18 </div> 16 19 17 <p> 18 <label for="remember_me">Remember me:</label> 19 <%= check_box_tag 'remember_me' %> 20 </p> 20 <div id="regular-login"> 21 <% form_tag session_path do -%> 22 <p> 23 <label for="email">Email</label><br/> 24 <%= text_field_tag 'email' %> 25 </p> 21 26 22 <p> 23 <%= submit_tag 'Log in' %> 24 <%= link_to 'Cancel', root_path %> 25 </p> 26 <% end -%> 27 <p> 28 <label for="password">Password</label><br/> 29 <%= password_field_tag 'password' %> 30 </p> 31 32 <p> 33 <label for="remember_me">Remember me:</label> 34 <%= check_box_tag 'remember_me' %> 35 </p> 36 37 <p> 38 <%= submit_tag 'Log in' %> 39 <%= link_to 'Cancel', root_path %> 40 </p> 41 <% end -%> 42 </div> 27 43 28 44 <p> incubator/jumpstart/app/views/users/forgot_password.html.erb
r251 r276 10 10 <%= text_field_tag :email %> 11 11 </p> 12 13 <%= submit_tag "Retrieve it" %>14 12 15 13 <p> 14 <%= submit_tag "Retrieve it" %> 16 15 <%= link_to 'Cancel', login_path %> 17 16 </p> incubator/jumpstart/app/views/users/new.html.erb
r271 r276 5 5 6 6 <%= error_messages_for :user %> 7 <div id="regular-signup"> 8 <% form_for @user do |f| -%> 9 <p> 10 <label for="username">Username</label><br/> 11 <%= f.text_field :username %> 12 </p> 7 13 8 <% form_for @user do |f| -%> 9 <p> 10 <label for="username">Username</label><br/> 11 <%= f.text_field :username %> 12 </p> 14 <p> 15 <label for="email">Email</label><br/> 16 <%= f.text_field :email %> 17 </p> 13 18 14 <p>15 <label for="email">Email</label><br/>16 <%= f.text_field :email%>17 </p>19 <p> 20 <label for="password">Password</label><br/> 21 <%= f.password_field :password %> 22 </p> 18 23 19 <p>20 <label for="password">Password</label><br/>21 <%= f.password_field :password%>22 </p>24 <p> 25 <label for="password_confirmation">Confirm Password</label><br/> 26 <%= f.password_field :password_confirmation %> 27 </p> 23 28 24 <p> 25 <label for="password_confirmation">Confirm Password</label><br/> 26 <%= f.password_field :password_confirmation %> 27 </p> 28 29 <p> 30 <%= submit_tag 'Sign up' %> 31 <%= link_to 'Cancel', root_path %> 32 </p> 33 <% end -%> 29 <p> 30 <%= submit_tag 'Sign up' %> 31 <%= link_to 'Cancel', root_path %> 32 </p> 33 <% end -%> 34 </div> 34 35 35 36 <p> 36 Already have an account ? <%= link_to 'Login now', login_path %><br />37 Already have an account or <span id="openid_url">OpenID</span>? <%= link_to 'Login now', login_path %><br /> 37 38 <%= link_to 'Forgot your password?', forgot_password_path %> 38 39 </p> incubator/jumpstart/app/views/welcome/index.html.erb
r271 r276 14 14 <%= link_to 'Logout', logout_path %> 15 15 <% else %> 16 Need an account? <%= link_to 'Sign up now', signup_path %><br /> 17 Already have an account? <%= link_to 'Login now', login_path %> 16 <%= link_to 'Login now', login_path %> 18 17 <% end %> 19 18 </p> incubator/jumpstart/config/routes.rb
r231 r276 1 1 ActionController::Routing::Routes.draw do |map| 2 map.root :controller => 'welcome', :action => 'index' 3 map.signup 'signup', :controller => 'users', :action => 'new' 4 map.activation 'activate', :controller => 'users', :action => 'activate' 5 map.login 'login', :controller => 'sessions', :action => 'new' 6 map.logout 'logout', :controller => 'sessions', :action => 'destroy' 7 map.forgot_password 'forgot_password', :controller => 'users', :action => 'forgot_password' 8 2 map.root :controller => 'welcome', :action => 'index' 3 map.signup 'signup', :controller => 'users', :action => 'new' 4 map.activation 'activate', :controller => 'users', :action => 'activate' 5 map.login 'login', :controller => 'sessions', :action => 'new' 6 map.logout 'logout', :controller => 'sessions', :action => 'destroy' 7 map.forgot_password 'forgot_password', :controller => 'users', :action => 'forgot_password' 8 map.open_id_complete 'session', :controller => "sessions", :action => "create", :requirements => { :method => :get } 9 9 10 map.resources :users 10 11 map.resource :session incubator/jumpstart/db/schema.rb
r275 r276 10 10 # It's strongly recommended to check this file into your version control system. 11 11 12 ActiveRecord::Schema.define(:version => 1) do 12 ActiveRecord::Schema.define(:version => 2) do 13 14 create_table "open_id_authentication_associations", :force => true do |t| 15 t.binary "server_url" 16 t.string "handle" 17 t.binary "secret" 18 t.integer "issued" 19 t.integer "lifetime" 20 t.string "assoc_type" 21 end 22 23 create_table "open_id_authentication_nonces", :force => true do |t| 24 t.string "nonce" 25 t.integer "created" 26 end 27 28 create_table "open_id_authentication_settings", :force => true do |t| 29 t.string "setting" 30 t.binary "value" 31 end 13 32 14 33 create_table "users", :force => true do |t| incubator/jumpstart/lib/authentable_entity.rb
r270 r276 11 11 attr_accessor :password 12 12 13 validates_presence_of :username 14 validates_length_of :username, :within => 3..40 15 validates_uniqueness_of :username, :case_sensitive => false 13 validates_presence_of :username, :if => :not_openid? 14 validates_length_of :username, :within => 3..40, :if => :not_openid? 15 validates_uniqueness_of :username, :case_sensitive => false, :allow_nil => true 16 16 17 validates_presence_of :email 18 validates_uniqueness_of :email, :case_sensitive => false 17 validates_presence_of :email, :if => :not_openid? 18 validates_uniqueness_of :email, :case_sensitive => false, :allow_nil => true 19 19 20 20 with_options :if => :password_required? do |new_password| … … 91 91 92 92 def password_required? 93 crypted_password.blank? || !password.blank? 93 not_openid? && (crypted_password.blank? || !password.blank?) 94 end 95 96 def not_openid? 97 identity_url.blank? 94 98 end 95 99 incubator/jumpstart/test/functional/users_controller_test.rb
r271 r276 111 111 112 112 put :update, :id => user.id 113 should.redirect_to edit_user_path user113 should.redirect_to edit_user_path(user) 114 114 end 115 115 incubator/jumpstart/vendor/gems/gems/ruby-openid-1.1.4/lib/openid/discovery.rb
r275 r276 6 6 begin 7 7 require 'rubygems' 8 require_gem 'ruby-yadis', ">=0.3.3"8 gem 'ruby-yadis', ">=0.3.3" 9 9 rescue LoadError 10 10 require "yadis" incubator/jumpstart/vendor/gems/gems/ruby-openid-1.1.4/lib/openid/service.rb
r275 r276 5 5 rescue LoadError 6 6 require 'rubygems' 7 require_gem 'ruby-yadis'7 gem 'ruby-yadis' 8 8 end 9 9 incubator/jumpstart/vendor/plugins
- Property svn:externals changed from
acts_as_authentable http://acts-as-authentable.googlecode.com/svn/trunk/acts_as_authentable
test_spec_on_rails http://svn.techno-weenie.net/projects/plugins/test_spec_on_rails
fixture_replacement2 http://thmadb.com/public_svn/plugins/fixture_replacement2
seo_helper http://opensource.thinkrelevance.com/svn/incubator/seo_helper
tarantula http://opensource.thinkrelevance.com/svn/rubygems/tarantula/trunk
to
acts_as_authentable http://acts-as-authentable.googlecode.com/svn/trunk/acts_as_authentable
test_spec_on_rails http://svn.techno-weenie.net/projects/plugins/test_spec_on_rails
fixture_replacement2 http://thmadb.com/public_svn/plugins/fixture_replacement2
seo_helper http://opensource.thinkrelevance.com/svn/incubator/seo_helper
tarantula http://opensource.thinkrelevance.com/svn/rubygems/tarantula/trunk
open_id_authentication http://svn.rubyonrails.org/rails/plugins/open_id_authentication
- Property svn:externals changed from
