authlogic_crowd 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/authlogic_crowd/session.rb +30 -1
- data/lib/authlogic_crowd/version.rb +1 -1
- metadata +4 -4
@@ -10,6 +10,15 @@ module AuthlogicCrowd
|
|
10
10
|
persist :persist_by_crowd, :if => :authenticating_with_crowd?
|
11
11
|
validate :validate_by_crowd, :if => [:authenticating_with_crowd?, :needs_crowd_validation?]
|
12
12
|
before_destroy :logout_of_crowd, :if => :authenticating_with_crowd?
|
13
|
+
before_persisting {|s| s.instance_variable_set('@persisted_by_crowd', false)}
|
14
|
+
after_persisting(:if => [:authenticating_with_crowd?, :persisted_by_crowd?, :explicit_login_from_crowd_token?], :unless => :new_registration?) do |s|
|
15
|
+
# The user was persisted via a crowd token (not an explicit login via username/password).
|
16
|
+
# Simulate explicit login by executing "save" callbacks.
|
17
|
+
s.before_save
|
18
|
+
s.new_session? ? s.before_create : s.before_update
|
19
|
+
s.new_session? ? s.after_create : s.after_update
|
20
|
+
s.after_save
|
21
|
+
end
|
13
22
|
after_create(:if => :authenticating_with_crowd?, :unless => :new_registration?) do |s|
|
14
23
|
synchronizer = s.crowd_synchronizer
|
15
24
|
synchronizer.local_record = s.record
|
@@ -40,6 +49,16 @@ module AuthlogicCrowd
|
|
40
49
|
rw_config(:auto_register,value,true)
|
41
50
|
end
|
42
51
|
alias_method :auto_register=, :auto_register
|
52
|
+
|
53
|
+
# Should login via a crowd token be treated as an explicit login?
|
54
|
+
# If true, explicit login callbacks ({before,after}_{create,update,save})
|
55
|
+
# will be triggered when a user is persisted. If false, the user is
|
56
|
+
# persisted but explicit login callbacks do not fire.
|
57
|
+
# Default false
|
58
|
+
def explicit_login_from_crowd_token(value=nil)
|
59
|
+
rw_config(:explicit_login_from_crowd_token, value, false)
|
60
|
+
end
|
61
|
+
alias_method :explicit_login_from_crowd_token=, :explicit_login_from_crowd_token
|
43
62
|
end
|
44
63
|
|
45
64
|
module InstanceMethods
|
@@ -63,6 +82,10 @@ module AuthlogicCrowd
|
|
63
82
|
auto_register?
|
64
83
|
end
|
65
84
|
|
85
|
+
def explicit_login_from_crowd_token?
|
86
|
+
!!self.class.explicit_login_from_crowd_token
|
87
|
+
end
|
88
|
+
|
66
89
|
def crowd_record
|
67
90
|
if @valid_crowd_user[:user_token] && !@valid_crowd_user.has_key?(:record)
|
68
91
|
@valid_crowd_user[:record] = crowd_client.find_user_by_token(@valid_crowd_user[:user_token])
|
@@ -101,7 +124,9 @@ module AuthlogicCrowd
|
|
101
124
|
clear_crowd_auth_cache
|
102
125
|
return false unless has_crowd_user_token? && valid_crowd_user_token? && crowd_username
|
103
126
|
self.unauthorized_record = find_or_create_record_from_crowd
|
104
|
-
valid?
|
127
|
+
return false unless valid?
|
128
|
+
@persisted_by_crowd = true
|
129
|
+
true
|
105
130
|
rescue SimpleCrowd::CrowdError => e
|
106
131
|
Rails.logger.warn "CROWD[#{__method__}]: Unexpected error. #{e}"
|
107
132
|
return false
|
@@ -339,6 +364,10 @@ module AuthlogicCrowd
|
|
339
364
|
!!controller.session[:"crowd.last_user_token"]
|
340
365
|
end
|
341
366
|
|
367
|
+
def persisted_by_crowd?
|
368
|
+
!!@persisted_by_crowd
|
369
|
+
end
|
370
|
+
|
342
371
|
def has_crowd_user_token?
|
343
372
|
!!crowd_user_token
|
344
373
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: authlogic_crowd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 3
|
10
|
+
version: 0.3.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Paul Strong
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-08-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
version_requirements: &id001 !ruby/object:Gem::Requirement
|