diff --git a/app/controllers/login_controller.rb b/app/controllers/login_controller.rb index 8dc6a3bd..91cfc261 100644 --- a/app/controllers/login_controller.rb +++ b/app/controllers/login_controller.rb @@ -96,7 +96,7 @@ class LoginController < ApplicationController session['noexpiry'] ||= params['user_noexpiry'] authenticate_with_open_id do |result, identity_url| if result.successful? - if @user = User.find_by_identity_url(identity_url) + if @user = User.find_by_open_id_url(identity_url) session['user_id'] = @user.id msg = (should_expire_sessions?) ? "will expire after 1 hour of inactivity." : "will not expire." notify :notice, "Login successful: session #{msg}" diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bad67adb..98f45cb9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -154,7 +154,7 @@ class UsersController < ApplicationController # error. If info is nil, it means that the user cancelled # the verification. @user.auth_type = 'open_id' - @user.identity_url = identity_url + @user.open_id_url = identity_url if @user.save notify :notice, "You have successfully verified #{identity_url} as your identity and set your authentication type to Open ID." else diff --git a/app/models/user.rb b/app/models/user.rb index 0330cead..6c0302cc 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -116,11 +116,11 @@ class User < ActiveRecord::Base validates_confirmation_of :password validates_length_of :login, :within => 3..80 validates_uniqueness_of :login, :on => :create - validates_presence_of :identity_url, :if => :using_openid? + validates_presence_of :open_id_url, :if => :using_openid? before_create :crypt_password, :generate_token before_update :crypt_password - before_save :normalize_identity_url + before_save :normalize_open_id_url #for will_paginate plugin cattr_accessor :per_page @@ -145,9 +145,9 @@ class User < ActiveRecord::Base return nil end - def self.find_by_identity_url(raw_identity_url) - normalized_identity_url = OpenIdAuthentication.normalize_url(raw_identity_url) - find(:first, :conditions => ['identity_url = ?', normalized_identity_url]) + def self.find_by_open_id_url(raw_identity_url) + normalized_open_id_url = OpenIdAuthentication.normalize_url(raw_identity_url) + find(:first, :conditions => ['open_id_url = ?', normalized_open_id_url]) end def self.no_users_yet? @@ -235,8 +235,8 @@ protected crypted_password == sha1(pass) end - def normalize_identity_url - return if identity_url.nil? - self.identity_url = OpenIdAuthentication.normalize_url(identity_url) + def normalize_open_id_url + return if open_id_url.nil? + self.open_id_url = OpenIdAuthentication.normalize_url(open_id_url) end end diff --git a/db/migrate/044_upgrade_open_id.rb b/db/migrate/044_upgrade_open_id.rb index 1ebd91ef..74307df9 100644 --- a/db/migrate/044_upgrade_open_id.rb +++ b/db/migrate/044_upgrade_open_id.rb @@ -12,8 +12,6 @@ class UpgradeOpenId < ActiveRecord::Migration t.string :salt, :null => false end - add_column :users, :identity_url, :string - drop_table :open_id_associations drop_table :open_id_nonces drop_table :open_id_settings @@ -41,7 +39,5 @@ class UpgradeOpenId < ActiveRecord::Migration t.string "setting" t.binary "value" end - - remove_column :users, :identity_url end end diff --git a/test/unit/user_test.rb b/test/unit/user_test.rb index 654d5a4e..26c5b0cb 100644 --- a/test/unit/user_test.rb +++ b/test/unit/user_test.rb @@ -326,18 +326,18 @@ class UserTest < Test::Rails::TestCase assert_nil users(:other_user).remember_token end - def test_normalizes_identity_url_on_save + def test_normalizes_open_id_url_on_save ['www.johndoe.com', 'WWW.JOHNDOE.COM', 'http://www.johndoe.com/', 'http://www.johndoe.com'].each do |initial| - assert_identity_url_normalized_on_save initial, 'http://www.johndoe.com/' + assert_open_id_url_normalized_on_save initial, 'http://www.johndoe.com/' end end - def test_normalizes_identity_url_on_find + def test_normalizes_open_id_url_on_find u = users(:other_user) - u.identity_url = 'http://www.johndoe.com' + u.open_id_url = 'http://www.johndoe.com' u.save - ['www.johndoe.com', 'WWW.JOHNDOE.COM', 'http://www.johndoe.com/', 'http://www.johndoe.com'].each do |raw_identity_url| - assert_equal u.id, User.find_by_identity_url(raw_identity_url).id + ['www.johndoe.com', 'WWW.JOHNDOE.COM', 'http://www.johndoe.com/', 'http://www.johndoe.com'].each do |raw_open_id_url| + assert_equal u.id, User.find_by_open_id_url(raw_open_id_url).id end end @@ -348,11 +348,11 @@ class UserTest < Test::Rails::TestCase User.create({ :login => 'quire', :password => 'quire', :password_confirmation => 'quire' }.merge(options)) end - def assert_identity_url_normalized_on_save(initial, expected) + def assert_open_id_url_normalized_on_save(initial, expected) u = users(:other_user) - u.identity_url = initial + u.open_id_url = initial u.save - assert_equal expected, u.identity_url + assert_equal expected, u.open_id_url end end