Skip to content

Commit

Permalink
update authlogic_rpx configuration for 1.1.0, and updte detail on use…
Browse files Browse the repository at this point in the history
…r profile path
  • Loading branch information
tardate committed Dec 29, 2009
1 parent b77609a commit 42823b6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 8 deletions.
30 changes: 25 additions & 5 deletions app/models/user.rb
@@ -1,11 +1,13 @@
class User < ActiveRecord::Base
acts_as_authentic
account_merge_enabled true
acts_as_authentic do |c|
c.account_mapping_mode :auto
c.account_merge_enabled true
end

attr_accessible :username, :email, :password, :password_confirmation, :rpx_identifier

validates_uniqueness_of :username, :case_sensitive => false

private

# map_added_rpx_data maps additional fields from the RPX response into the user object during the "add RPX to existing account" process.
Expand All @@ -15,9 +17,27 @@ class User < ActiveRecord::Base
# "self" at this point is the user model. Map details as appropriate from the rpx_data structure provided.
#
def map_added_rpx_data( rpx_data )

# map some additional fields, e.g. photo_url
self.photo_url = rpx_data['profile']['photo'] if photo_url.blank?
end


# before_merge_rpx_data provides a hook for application developers to perform data migration prior to the merging of user accounts.
# This method is called just before authlogic_rpx merges the user registration for 'from_user' into 'to_user'
# Authlogic_RPX is responsible for merging registration data.
#
# By default, it does not merge any other details (e.g. application data ownership)
#
def before_merge_rpx_data( from_user, to_user )
RAILS_DEFAULT_LOGGER.info "in before_merge_rpx_data"
end

# after_merge_rpx_data provides a hook for application developers to perform account clean-up after authlogic_rpx has
# migrated registration details.
#
# By default, does nothing. It could, for example, be used to delete or disable the 'from_user' account
#
def after_merge_rpx_data( from_user, to_user )
RAILS_DEFAULT_LOGGER.info "in after_merge_rpx_data"
end

end
7 changes: 4 additions & 3 deletions app/views/users/show.html.erb
Expand Up @@ -14,19 +14,20 @@
<ul>
<li>Password authentication has <%= @user.using_password? ? "been enabled" : "<b>not</b> been enabled" %></li>
<li>RPX authentication has <%= @user.using_rpx? ? "been enabled" : "<b>not</b> been enabled" %></li>
<li>RPX account merging enabled?: <%= @user.class.account_merge_enabled_value %></li>
<li>RPX selected mapping mode: <%= @user.class.account_mapping_mode_value %></li>
<li>RPX mapping mode in use: <%= @user.class.account_mapping_mode_used %></li>
</ul>
</p>

<% if @user.using_rpx? %>
<p>
<b>RPX Authentication Providers:</b>
<ul>
<% @user.rpx_identifiers.each do |identifier| %>
<li>Provider: <%= identifier.provider_name %>, ID: <%= identifier.identifier %></li>
<li>Provider: <%= identifier[:provider_name] %>, ID: <%= identifier[:identifier] %></li>
<% end %>
</ul>
</p>
<% end %>

<p>
<b>Authlogic extended attributes:</b>
Expand Down

0 comments on commit 42823b6

Please sign in to comment.