Empact-authlogic_rpx 1.1.8 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Empact-authlogic_rpx.gemspec +46 -68
- data/VERSION +1 -1
- data/lib/authlogic_rpx.rb +3 -2
- data/lib/authlogic_rpx/acts_as_authentic.rb +251 -255
- data/lib/authlogic_rpx/helper.rb +33 -33
- data/lib/authlogic_rpx/railtie.rb +9 -0
- data/lib/authlogic_rpx/rpx_identifier.rb +2 -2
- data/lib/authlogic_rpx/session.rb +236 -236
- data/test/unit/verify_rpx_mock_test.rb +4 -4
- metadata +40 -86
- data/.gitignore +0 -1
@@ -1,90 +1,68 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{Empact-authlogic_rpx}
|
8
|
-
s.version = "
|
8
|
+
s.version = "2.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date = %q{
|
11
|
+
s.authors = [%q{Paul Gallagher / tardate}]
|
12
|
+
s.date = %q{2011-09-12}
|
13
13
|
s.description = %q{Authlogic extension/plugin that provides RPX (rpxnow.com) authentication support}
|
14
14
|
s.email = %q{gallagher.paul@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.rdoc"
|
17
17
|
]
|
18
18
|
s.files = [
|
19
|
-
".
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
19
|
+
"CHANGELOG.rdoc",
|
20
|
+
"Empact-authlogic_rpx.gemspec",
|
21
|
+
"MIT-LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"generators/add_authlogic_rpx_migration/USAGE",
|
26
|
+
"generators/add_authlogic_rpx_migration/add_authlogic_rpx_migration_generator.rb",
|
27
|
+
"generators/add_authlogic_rpx_migration/templates/migration_internal_mapping.rb",
|
28
|
+
"generators/add_authlogic_rpx_migration/templates/migration_no_mapping.rb",
|
29
|
+
"init.rb",
|
30
|
+
"lib/authlogic_rpx.rb",
|
31
|
+
"lib/authlogic_rpx/acts_as_authentic.rb",
|
32
|
+
"lib/authlogic_rpx/helper.rb",
|
33
|
+
"lib/authlogic_rpx/railtie.rb",
|
34
|
+
"lib/authlogic_rpx/rpx_identifier.rb",
|
35
|
+
"lib/authlogic_rpx/session.rb",
|
36
|
+
"lib/authlogic_rpx/session/validation.rb",
|
37
|
+
"lib/authlogic_rpx/version.rb",
|
38
|
+
"rails/init.rb",
|
39
|
+
"test/fixtures/rpxresponses.yml",
|
40
|
+
"test/fixtures/users.yml",
|
41
|
+
"test/integration/basic_authentication_and_registration_test.rb",
|
42
|
+
"test/integration/internal_mapping/basic_authentication_and_registration_test.rb",
|
43
|
+
"test/integration/internal_mapping/settings_test.rb",
|
44
|
+
"test/integration/no_mapping/basic_authentication_and_registration_test.rb",
|
45
|
+
"test/integration/no_mapping/settings_test.rb",
|
46
|
+
"test/libs/ext_test_unit.rb",
|
47
|
+
"test/libs/mock_rpx_now.rb",
|
48
|
+
"test/libs/rails_trickery.rb",
|
49
|
+
"test/libs/rpxresponse.rb",
|
50
|
+
"test/libs/user.rb",
|
51
|
+
"test/libs/user_session.rb",
|
52
|
+
"test/test_helper.rb",
|
53
|
+
"test/test_internal_mapping_helper.rb",
|
54
|
+
"test/unit/acts_as_authentic_settings_test.rb",
|
55
|
+
"test/unit/helpers_test.rb",
|
56
|
+
"test/unit/session_settings_test.rb",
|
57
|
+
"test/unit/session_validation_test.rb",
|
58
|
+
"test/unit/verify_rpx_mock_test.rb"
|
59
59
|
]
|
60
60
|
s.homepage = %q{http://github.com/tardate/authlogic_rpx}
|
61
|
-
s.
|
62
|
-
s.
|
63
|
-
s.rubygems_version = %q{1.3.7}
|
61
|
+
s.require_paths = [%q{lib}]
|
62
|
+
s.rubygems_version = %q{1.8.8}
|
64
63
|
s.summary = %q{Authlogic plug-in for RPX support}
|
65
|
-
s.test_files = [
|
66
|
-
"test/integration/basic_authentication_and_registration_test.rb",
|
67
|
-
"test/integration/internal_mapping/basic_authentication_and_registration_test.rb",
|
68
|
-
"test/integration/internal_mapping/settings_test.rb",
|
69
|
-
"test/integration/no_mapping/basic_authentication_and_registration_test.rb",
|
70
|
-
"test/integration/no_mapping/settings_test.rb",
|
71
|
-
"test/libs/ext_test_unit.rb",
|
72
|
-
"test/libs/mock_rpx_now.rb",
|
73
|
-
"test/libs/rails_trickery.rb",
|
74
|
-
"test/libs/rpxresponse.rb",
|
75
|
-
"test/libs/user.rb",
|
76
|
-
"test/libs/user_session.rb",
|
77
|
-
"test/test_helper.rb",
|
78
|
-
"test/test_internal_mapping_helper.rb",
|
79
|
-
"test/unit/acts_as_authentic_settings_test.rb",
|
80
|
-
"test/unit/helpers_test.rb",
|
81
|
-
"test/unit/session_settings_test.rb",
|
82
|
-
"test/unit/session_validation_test.rb",
|
83
|
-
"test/unit/verify_rpx_mock_test.rb"
|
84
|
-
]
|
85
64
|
|
86
65
|
if s.respond_to? :specification_version then
|
87
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
88
66
|
s.specification_version = 3
|
89
67
|
|
90
68
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
data/lib/authlogic_rpx.rb
CHANGED
@@ -6,9 +6,10 @@ require "authlogic_rpx/session/validation"
|
|
6
6
|
require "authlogic_rpx/helper"
|
7
7
|
require "authlogic_rpx/rpx_identifier"
|
8
8
|
|
9
|
-
ActiveRecord::Base.send(:include, AuthlogicRpx::ActsAsAuthentic)
|
10
9
|
Authlogic::Session::Base.class_eval do
|
11
10
|
include AuthlogicRpx::Session::Validation
|
12
11
|
include AuthlogicRpx::Session
|
13
12
|
end
|
14
|
-
ActionController::Base.helper AuthlogicRpx::Helper
|
13
|
+
ActionController::Base.helper AuthlogicRpx::Helper
|
14
|
+
|
15
|
+
require 'authlogic_rpx/railtie' if defined?(Rails)
|
@@ -1,276 +1,272 @@
|
|
1
1
|
# This module is responsible for adding RPX functionality to Authlogic. Checkout the README for more info and please
|
2
2
|
# see the sub modules for detailed documentation.
|
3
3
|
module AuthlogicRpx
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
4
|
+
# This module is responsible for adding in the RPX functionality to your models. It hooks itself into the
|
5
|
+
# acts_as_authentic method provided by Authlogic.
|
6
|
+
module ActsAsAuthentic
|
7
|
+
# Adds in the neccesary modules for acts_as_authentic to include and also disabled password validation if
|
8
|
+
# RPX is being used.
|
9
|
+
def self.included(klass)
|
10
|
+
klass.class_eval do
|
11
|
+
extend Config
|
12
|
+
add_acts_as_authentic_module(Methods, :prepend)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class GeneralError < StandardError
|
17
|
+
end
|
18
|
+
class ConfigurationError < StandardError
|
19
|
+
end
|
20
|
+
|
21
|
+
module Config
|
22
|
+
|
23
|
+
# account_merge_enabled is used to enable merging of accounts.
|
24
|
+
#
|
25
|
+
# * <tt>Default:</tt> false
|
26
|
+
# * <tt>Accepts:</tt> boolean
|
27
|
+
def account_merge_enabled(value=false)
|
28
|
+
account_merge_enabled_value(value)
|
29
|
+
end
|
30
|
+
def account_merge_enabled_value(value=nil)
|
31
|
+
rw_config(:account_merge_enabled,value,false)
|
32
|
+
end
|
33
|
+
alias_method :account_merge_enabled=,:account_merge_enabled
|
34
|
+
|
35
|
+
|
36
|
+
# account_mapping_mode is used to explicitly set/override the mapping behaviour.
|
37
|
+
#
|
38
|
+
# * <tt>Default:</tt> :auto
|
39
|
+
# * <tt>Accepts:</tt> :auto, :none, :internal, :rpxnow
|
40
|
+
def account_mapping_mode(value=:auto)
|
41
|
+
account_mapping_mode_value(value)
|
42
|
+
end
|
43
|
+
def account_mapping_mode_value(value=nil)
|
44
|
+
raise AuthlogicRpx::ActsAsAuthentic::ConfigurationError.new unless value.nil? || [:auto,:none,:internal].include?( value )
|
45
|
+
rw_config(:account_mapping_mode,value,:auto)
|
46
|
+
end
|
47
|
+
alias_method :account_mapping_mode=,:account_mapping_mode
|
48
|
+
|
49
|
+
# returns the actual account mapping mode in use - resolves :auto to actual mechanism
|
50
|
+
#
|
51
|
+
attr_writer :account_mapping_mode_used
|
52
|
+
def account_mapping_mode_used
|
53
|
+
@account_mapping_mode_used ||=
|
54
|
+
if account_mapping_mode_value != :auto
|
55
|
+
account_mapping_mode_value
|
56
|
+
elsif RPXIdentifier.table_exists?
|
57
|
+
:internal
|
58
|
+
elsif self.column_names.include?("rpx_identifier")
|
59
|
+
:none
|
60
|
+
else
|
61
|
+
AuthlogicRpx::ActsAsAuthentic::ConfigurationError.new
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
# determines if no account mapping is supported (the only behaviour in authlogic_rpx v1.0.4)
|
67
|
+
def using_no_mapping?
|
68
|
+
account_mapping_mode_used == :none
|
69
|
+
end
|
70
|
+
# determines if internal account mapping is enabled (behaviour added in authlogic_rpx v1.1.0)
|
71
|
+
def using_internal_mapping?
|
72
|
+
account_mapping_mode_used == :internal
|
73
|
+
end
|
74
|
+
# determines if rpxnow account mapping is enabled (currently not implemented)
|
75
|
+
def using_rpx_mapping?
|
76
|
+
account_mapping_mode_used == :rpxnow
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
module Methods
|
82
|
+
|
83
|
+
# Set up some simple validations
|
84
|
+
def self.included(klass)
|
85
|
+
klass.class_eval do
|
86
|
+
|
87
|
+
case
|
88
|
+
when using_no_mapping?
|
89
|
+
alias_method :using_rpx?, :using_rpx__nomap?
|
90
|
+
alias_method :add_rpx_identifier, :add_rpx_identifier__nomap
|
91
|
+
alias_method :identified_by?, :identified_by__nomap?
|
92
|
+
alias_method :merge_user_id, :merge_user_id__nomap
|
93
|
+
|
94
|
+
# Uses default find_by_rpx_identifier class method
|
95
|
+
|
96
|
+
# Add an rpx_identifier collection method
|
97
|
+
def rpx_identifiers
|
98
|
+
[{ :identifier => rpx_identifier, :provider_name => "Unknown" }]
|
99
|
+
end
|
100
|
+
|
101
|
+
when using_internal_mapping?
|
102
|
+
alias_method :using_rpx?, :using_rpx__internal?
|
103
|
+
alias_method :add_rpx_identifier, :add_rpx_identifier__internal
|
104
|
+
alias_method :identified_by?, :identified_by__internal?
|
105
|
+
alias_method :merge_user_id, :merge_user_id__internal
|
104
106
|
has_many :rpx_identifiers, :class_name => 'RPXIdentifier', :validate => false, :dependent => :destroy
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
end
|
121
|
-
else
|
122
|
-
identifier.send( self.class_name.downcase )
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
107
|
+
|
108
|
+
# Add custom find_by_rpx_identifier class method
|
109
|
+
#
|
110
|
+
def self.find_by_rpx_identifier(id)
|
111
|
+
if identifier = RPXIdentifier.find_by_identifier(id)
|
112
|
+
identifier.send(self.model_name.downcase )
|
113
|
+
elsif self.column_names.include? 'rpx_identifier'
|
114
|
+
# check for authentication using <=1.0.4, migrate identifier to rpx_identifiers table
|
115
|
+
if user = self.find( :first, :conditions => [ "rpx_identifier = ?", id ] )
|
116
|
+
user.add_rpx_identifier( id, 'Unknown' )
|
117
|
+
end
|
118
|
+
user
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
126
122
|
else
|
127
123
|
raise AuthlogicRpx::ActsAsAuthentic::ConfigurationError.new( "invalid or unsupported account_mapping_mode" )
|
128
124
|
end
|
129
125
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
126
|
+
validates_length_of_password_field_options validates_length_of_password_field_options.merge(:if => :validate_password_with_rpx?)
|
127
|
+
validates_confirmation_of_password_field_options validates_confirmation_of_password_field_options.merge(:if => :validate_password_with_rpx?)
|
128
|
+
validates_length_of_password_confirmation_field_options validates_length_of_password_confirmation_field_options.merge(:if => :validate_password_with_rpx?)
|
129
|
+
|
130
|
+
before_validation :adding_rpx_identifier
|
131
|
+
end
|
136
132
|
|
137
133
|
# add relations and validation to RPXIdentifier based on the actual user model class name used
|
138
134
|
#
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
135
|
+
RPXIdentifier.class_eval do
|
136
|
+
belongs_to klass.name.downcase.to_sym
|
137
|
+
validates_presence_of "#{klass.name.downcase}_id".to_sym
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# test if account it using RPX authentication
|
142
|
+
# aliased to using_rpx based on authlogic_rpx configuration mode
|
143
|
+
def using_rpx__nomap?
|
144
|
+
!rpx_identifier.blank?
|
145
|
+
end
|
146
|
+
def using_rpx__internal?
|
147
|
+
!rpx_identifiers.empty?
|
148
|
+
end
|
149
|
+
|
150
|
+
# test if account it using normal password authentication
|
151
|
+
def using_password?
|
152
|
+
!send(crypted_password_field).blank?
|
153
|
+
end
|
158
154
|
|
159
155
|
# adds RPX identification to the instance.
|
160
156
|
# Abstracts how the RPX identifier is added to allow for multiplicity of underlying implementations
|
161
|
-
|
157
|
+
# aliased to add_rpx_identifier based on authlogic_rpx configuration mode
|
162
158
|
def add_rpx_identifier__nomap( rpx_id, rpx_provider_name )
|
163
|
-
|
164
|
-
|
159
|
+
self.rpx_identifier = rpx_id
|
160
|
+
#TODO: make rpx_provider_name a std param?
|
165
161
|
end
|
166
162
|
def add_rpx_identifier__internal( rpx_id, rpx_provider_name )
|
167
|
-
|
163
|
+
self.rpx_identifiers.build(:identifier => rpx_id, :provider_name => rpx_provider_name )
|
168
164
|
end
|
169
|
-
|
165
|
+
|
170
166
|
# Checks if given identifier is an identity for this account
|
171
167
|
# aliased to identified_by based on authlogic_rpx configuration mode
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
168
|
+
def identified_by__nomap?( id )
|
169
|
+
self.rpx_identifier == id
|
170
|
+
end
|
171
|
+
def identified_by__internal?( id )
|
172
|
+
self.rpx_identifiers.find_by_identifier( id )
|
173
|
+
end
|
174
|
+
|
175
|
+
private
|
176
|
+
|
177
|
+
# tests if password authentication should be checked: if rpx is enabled (but not used by this user)
|
178
|
+
def validate_password_with_rpx?
|
179
|
+
!using_rpx? && require_password?
|
180
|
+
end
|
181
|
+
|
182
|
+
# determines if account merging is enabled; delegates to class method
|
183
|
+
def account_merge_enabled?
|
184
|
+
self.class.account_merge_enabled_value
|
185
|
+
end
|
186
|
+
|
187
|
+
# hook for adding RPX identifier to an existing account. This is invoked prior to model validation.
|
188
|
+
# RPX information is plucked from the controller session object (where it was placed by the session model as a result
|
189
|
+
# of the RPX callback)
|
190
|
+
# The minimal action taken is to add an RPXIdentifier object to the user.
|
191
|
+
#
|
192
|
+
# This procedure chains to the map_added_rpx_data, which may be over-ridden in your project to perform
|
193
|
+
# additional mapping of RPX information to the user model as may be desired.
|
194
|
+
#
|
195
|
+
def adding_rpx_identifier
|
196
|
+
return true unless session_class && session_class.controller
|
197
|
+
|
198
|
+
added_rpx_data = session_class.controller.session['added_rpx_data']
|
199
|
+
unless added_rpx_data.blank?
|
200
|
+
session_class.controller.session['added_rpx_data'] = nil
|
201
|
+
rpx_id = added_rpx_data['profile']['identifier']
|
202
|
+
rpx_provider_name = added_rpx_data['profile']['providerName']
|
203
|
+
|
204
|
+
unless self.identified_by?( rpx_id )
|
205
|
+
# identifier not already set for this user..
|
206
|
+
|
207
|
+
another_user = self.class.find_by_rpx_identifier( rpx_id )
|
208
|
+
if another_user
|
209
|
+
return false unless account_merge_enabled?
|
210
|
+
# another user already has this id registered..
|
211
|
+
|
212
|
+
# merge all IDs from another_user to self, with application callbacks before/after
|
213
|
+
before_merge_rpx_data( another_user, self )
|
214
|
+
merge_user_id another_user
|
215
|
+
after_merge_rpx_data( another_user, self )
|
216
|
+
|
217
|
+
else
|
218
|
+
self.add_rpx_identifier( rpx_id, rpx_provider_name )
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
map_added_rpx_data( added_rpx_data )
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
# merge_user_id is an internal method used to merge the actual RPX identifiers
|
227
|
+
# aliased to merge_user_id based on authlogic_rpx configuration mode
|
228
|
+
def merge_user_id__nomap( from_user )
|
229
|
+
self.rpx_identifier = from_user.rpx_identifier
|
230
|
+
from_user.rpx_identifier = nil
|
231
|
+
from_user.save
|
232
|
+
from_user.reload
|
233
|
+
end
|
234
|
+
def merge_user_id__internal( from_user )
|
235
|
+
self.rpx_identifiers << from_user.rpx_identifiers
|
236
|
+
from_user.reload
|
237
|
+
end
|
238
|
+
|
239
|
+
|
240
|
+
# map_added_rpx_data maps additional fields from the RPX response into the user object during the "add RPX to existing account" process.
|
241
|
+
# Override this in your user model to perform field mapping as may be desired
|
242
|
+
# See https://rpxnow.com/docs#profile_data for the definition of available attributes
|
243
|
+
#
|
244
|
+
# "self" at this point is the user model. Map details as appropriate from the rpx_data structure provided.
|
245
|
+
#
|
246
|
+
def map_added_rpx_data( rpx_data )
|
247
|
+
|
248
|
+
end
|
249
|
+
|
250
|
+
# before_merge_rpx_data provides a hook for application developers to perform data migration prior to the merging of user accounts.
|
251
|
+
# This method is called just before authlogic_rpx merges the user registration for 'from_user' into 'to_user'
|
252
|
+
# Authlogic_RPX is responsible for merging registration data.
|
253
|
+
#
|
254
|
+
# By default, it does not merge any other details (e.g. application data ownership)
|
255
|
+
#
|
256
|
+
def before_merge_rpx_data( from_user, to_user )
|
257
|
+
|
258
|
+
end
|
259
|
+
|
260
|
+
# after_merge_rpx_data provides a hook for application developers to perform account clean-up after authlogic_rpx has
|
261
|
+
# migrated registration details.
|
262
|
+
#
|
263
|
+
# By default, does nothing. It could, for example, be used to delete or disable the 'from_user' account
|
264
|
+
#
|
265
|
+
def after_merge_rpx_data( from_user, to_user )
|
266
|
+
|
267
|
+
end
|
268
|
+
|
269
|
+
|
270
|
+
end
|
271
|
+
end
|
276
272
|
end
|