reflex 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.rdoc +2 -6
- data/Rakefile +33 -9
- data/VERSION +1 -1
- data/lib/reflex/authlogic/account.rb +9 -7
- data/lib/reflex/authlogic/authentication_process.rb +2 -1
- data/lib/reflex/authlogic/callback_filter.rb +1 -1
- data/lib/reflex/authlogic/connectable.rb +4 -0
- data/lib/reflex/authlogic/session.rb +11 -2
- data/lib/reflex/base.rb +1 -1
- data/rails_generators/reflex_connection_migration/templates/create_reflex_connections.rb +1 -1
- data/reflex.gemspec +2 -2
- metadata +3 -3
data/README.rdoc
CHANGED
@@ -14,11 +14,6 @@ use it as a basis, if you get stuck.
|
|
14
14
|
|
15
15
|
=== 2. Install Reflex
|
16
16
|
|
17
|
-
*WARNING!* Because the reflex gem is not yet available, the notes below are incorrect. For now,
|
18
|
-
simply install reflex as a rails plugin and _don't_ add it in your environment.rb or Gemfile:
|
19
|
-
|
20
|
-
$ script/plugin install git@github.com:i76/reflex.git
|
21
|
-
|
22
17
|
Add the gem dependencies in your config:
|
23
18
|
|
24
19
|
==== Rails 2.3
|
@@ -42,7 +37,6 @@ Add the dependencies to your Gemfile
|
|
42
37
|
And install them:
|
43
38
|
|
44
39
|
$ bundle install
|
45
|
-
$ bundle lock
|
46
40
|
|
47
41
|
=== 3. Generate the reflex_connections migration
|
48
42
|
|
@@ -179,6 +173,8 @@ The reflex gem is far from finished. Here are some of the upcoming features:
|
|
179
173
|
then it should be a matter of calling:
|
180
174
|
`@user.twitter.update_status("I've connected my Twitter profile")`
|
181
175
|
|
176
|
+
2. Better support for connecting a previously connected user
|
177
|
+
|
182
178
|
== Note on Patches/Pull Requests
|
183
179
|
|
184
180
|
* Fork the project.
|
data/Rakefile
CHANGED
@@ -27,16 +27,40 @@ rescue LoadError
|
|
27
27
|
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
begin
|
31
|
+
# Rspec 1.3.0
|
32
|
+
require 'spec/rake/spectask'
|
33
|
+
|
34
|
+
desc 'Default: run specs'
|
35
|
+
task :default => :spec
|
36
|
+
Spec::Rake::SpecTask.new do |t|
|
37
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
38
|
+
end
|
35
39
|
|
36
|
-
Spec::Rake::SpecTask.new(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
+
Spec::Rake::SpecTask.new('rcov') do |t|
|
41
|
+
t.spec_files = FileList["spec/**/*_spec.rb"]
|
42
|
+
t.rcov = true
|
43
|
+
t.rcov_opts = ['--exclude', 'spec']
|
44
|
+
end
|
45
|
+
|
46
|
+
rescue LoadError
|
47
|
+
# Rspec 2.0
|
48
|
+
require 'rspec/core/rake_task'
|
49
|
+
|
50
|
+
desc 'Default: run specs'
|
51
|
+
task :default => :spec
|
52
|
+
Rspec::Core::RakeTask.new do |t|
|
53
|
+
t.pattern = "spec/**/*_spec.rb"
|
54
|
+
end
|
55
|
+
|
56
|
+
Rspec::Core::RakeTask.new('rcov') do |t|
|
57
|
+
t.pattern = "spec/**/*_spec.rb"
|
58
|
+
t.rcov = true
|
59
|
+
t.rcov_opts = ['--exclude', 'spec']
|
60
|
+
end
|
61
|
+
|
62
|
+
rescue LoadError
|
63
|
+
puts "Rspec not available. Install it with: gem install rspec"
|
40
64
|
end
|
41
65
|
|
42
66
|
task :spec => :check_dependencies
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
@@ -10,11 +10,14 @@ module Reflex
|
|
10
10
|
|
11
11
|
# Overwrite authlogic validation options so they are skipped when saving a react account:
|
12
12
|
[:validates_uniqueness_of_login_field_options,
|
13
|
+
:validates_length_of_login_field_options,
|
14
|
+
:validates_format_of_login_field_options,
|
15
|
+
:validates_uniqueness_of_email_field_options,
|
16
|
+
:validates_length_of_email_field_options,
|
17
|
+
:validates_format_of_email_field_options,
|
13
18
|
:validates_length_of_password_field_options,
|
14
19
|
:validates_confirmation_of_password_field_options,
|
15
|
-
:validates_length_of_password_confirmation_field_options
|
16
|
-
:validates_length_of_login_field_options,
|
17
|
-
:validates_format_of_login_field_options].each do |validate_options|
|
20
|
+
:validates_length_of_password_confirmation_field_options].each do |validate_options|
|
18
21
|
current_options = base.send(validate_options)
|
19
22
|
|
20
23
|
base.cattr_accessor "original_#{validate_options}"
|
@@ -42,11 +45,10 @@ module Reflex
|
|
42
45
|
record = new()
|
43
46
|
connection = record.reflex_connections.build(:provider => provider)
|
44
47
|
|
45
|
-
if react_profile
|
46
|
-
|
47
|
-
end
|
48
|
-
|
48
|
+
record.react_profile = react_profile if record.respond_to?(:react_profile=)
|
49
|
+
record.persistence_token = ::Authlogic::Random.hex_token if record.respond_to?(:persistence_token=)
|
49
50
|
record.save_without_session_maintenance
|
51
|
+
|
50
52
|
[record, connection]
|
51
53
|
end
|
52
54
|
end
|
@@ -16,8 +16,9 @@ module Reflex
|
|
16
16
|
reflex_controller.redirect_to(result['redirectUrl'])
|
17
17
|
end
|
18
18
|
|
19
|
+
|
19
20
|
def react_provider
|
20
|
-
|
21
|
+
reflex_controller.params && reflex_controller.params['react_provider']
|
21
22
|
end
|
22
23
|
|
23
24
|
def react_oauth_session
|
@@ -8,7 +8,7 @@ module Reflex
|
|
8
8
|
def call(env)
|
9
9
|
# if :react_callback_method is available in the session and the requested URL's query
|
10
10
|
# contains ReactOAuthSession, change the REQUEST_METHOD to :react_callback_method
|
11
|
-
if env["rack.session"][:react_callback_method].present? && env["QUERY_STRING"] =~ /ReactOAuthSession/
|
11
|
+
if env["rack.session"][:react_callback_method].present? && env["QUERY_STRING"] =~ /ReactOAuthSession/
|
12
12
|
env["REQUEST_METHOD"] = env["rack.session"].delete(:react_callback_method).to_s.upcase
|
13
13
|
|
14
14
|
if env["rack.session"][:react_callback_location].present?
|
@@ -25,6 +25,15 @@ module Reflex
|
|
25
25
|
|
26
26
|
private
|
27
27
|
|
28
|
+
def react_provider
|
29
|
+
reflex_controller.params && reflex_controller.params['react_provider']
|
30
|
+
end
|
31
|
+
|
32
|
+
# If we are already logged in, we are not going to authenticate again!
|
33
|
+
def authenticating_via_oauth_server?
|
34
|
+
attempted_record.nil? && errors.empty? && super
|
35
|
+
end
|
36
|
+
|
28
37
|
def authenticate_oauth_session(allow_retry = true)
|
29
38
|
# Request the React Session
|
30
39
|
oauth_session = Reflex::OAuthServer.token_access(reflex_controller.params)
|
@@ -46,10 +55,10 @@ module Reflex
|
|
46
55
|
else
|
47
56
|
# User is not yet known on React's side, so create it:
|
48
57
|
react_profile = Reflex::OAuthServer.session_get_profile(react_oauth_session)
|
49
|
-
|
58
|
+
|
50
59
|
# Create a user record with a connection to this provider
|
51
60
|
self.attempted_record, connection = klass.create_for_react(react_provider, react_profile)
|
52
|
-
|
61
|
+
|
53
62
|
if !attempted_record.new_record?
|
54
63
|
# Set the user id on react's side:
|
55
64
|
Reflex::OAuthServer.token_set_user_id(connection.uuid, react_oauth_session)
|
data/lib/reflex/base.rb
CHANGED
@@ -3,7 +3,7 @@ require 'xmlrpc/client'
|
|
3
3
|
# unfortunately react's oauth server has <nil />'s, which the ruby XMLRPC
|
4
4
|
# library does not enable by default, because it is an XML-RPC extension:
|
5
5
|
# http://ontosys.com/xml-rpc/extensions.php
|
6
|
-
old_verbose, $VERBOSE = $VERBOSE, nil
|
6
|
+
old_verbose, $VERBOSE = $VERBOSE, nil
|
7
7
|
begin
|
8
8
|
XMLRPC::Config::ENABLE_NIL_PARSER = true
|
9
9
|
XMLRPC::Config::ENABLE_NIL_CREATE = true
|
@@ -8,7 +8,7 @@ class CreateReflexConnections < ActiveRecord::Migration
|
|
8
8
|
t.timestamps
|
9
9
|
end
|
10
10
|
|
11
|
-
add_index :reflex_connections, [:authorizable_type, :authorizable_id], :unique => false
|
11
|
+
add_index :reflex_connections, [:authorizable_type, :authorizable_id], :unique => false, :name => 'reflex_connection_authorizable'
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.down
|
data/reflex.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{reflex}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Tom-Eric Gerritsen"]
|
12
|
-
s.date = %q{2010-05-
|
12
|
+
s.date = %q{2010-05-03}
|
13
13
|
s.description = %q{Reflex is a gem that allows you to connect your application to the React Social API}
|
14
14
|
s.email = %q{tomeric@i76.nl}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 3
|
9
|
+
version: 0.0.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Tom-Eric Gerritsen
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-05-
|
17
|
+
date: 2010-05-03 00:00:00 +02:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|