appoxy_rails 0.0.21 → 0.0.22

Sign up to get free protection for your applications and to get access to all the features.
@@ -118,7 +118,7 @@ module Appoxy
118
118
 
119
119
  def facebook_oauth_url(options={})
120
120
  # puts 'appconfig==' + Rails.application.config.inspect
121
- raise "Please config your facebook id and rails keys." unless ::Rails.application.config.respond_to?(:facebook_app_id)
121
+ raise "Please config your facebook id and api keys." unless ::Rails.application.config.respond_to?(:facebook_app_id)
122
122
  raise "Scope must be specified." unless options[:scope]
123
123
  app_id = ::Rails.application.config.facebook_app_id
124
124
  if app_id
@@ -42,7 +42,7 @@ module Appoxy
42
42
 
43
43
  @has_password = params[:has_password]
44
44
  #puts 'has_pass? ' + @has_password.inspect
45
- @az_style = params[:az_style]
45
+ @az_style = params[:az_style]
46
46
 
47
47
  if @az_style
48
48
  if params[:has_password].blank?
@@ -62,7 +62,7 @@ module Appoxy
62
62
  # user = User.authenticate(@email, params[:password])
63
63
  if user && user.authenticate(params[:password])
64
64
  self.current_user = user
65
- user.last_login = Time.now
65
+ user.last_login = Time.now
66
66
  user.save(:dirty=>true)
67
67
  flash[:info] = "Logged in successfully."
68
68
  after_create
@@ -104,7 +104,7 @@ module Appoxy
104
104
  return
105
105
  end
106
106
 
107
- @newpass = random_string(8)
107
+ @newpass = random_string(8)
108
108
 
109
109
  @user.password = @newpass
110
110
  @user.save(:dirty=>true)
@@ -176,7 +176,7 @@ module Appoxy
176
176
  oidreq.return_to_args['force_post']='x'*2048
177
177
  end
178
178
  return_to = base_url + "/sessions/openid_complete"
179
- realm = base_url
179
+ realm = base_url
180
180
 
181
181
  puts 'about to redirect'
182
182
 
@@ -197,7 +197,7 @@ module Appoxy
197
197
 
198
198
  return if before_create == false
199
199
 
200
- temp1 = session
200
+ temp1 = session
201
201
 
202
202
  current_url = base_url + "/sessions/openid_complete" # url_for(:action => 'complete', :only_path => false)
203
203
  puts 'current_url=' + current_url.inspect
@@ -219,7 +219,7 @@ module Appoxy
219
219
 
220
220
  user_data[:open_id] = oidresp.identity_url
221
221
  if params[:did_ax]
222
- sreg_resp = OpenID::AX::FetchResponse.from_success_response(oidresp)
222
+ sreg_resp = OpenID::AX::FetchResponse.from_success_response(oidresp)
223
223
  sreg_message = "AX Registration data was requested"
224
224
  if sreg_resp.data.empty?
225
225
  sreg_message << ", but none was returned."
@@ -233,7 +233,7 @@ module Appoxy
233
233
  puts sreg_message
234
234
  end
235
235
  if params[:did_sreg]
236
- sreg_resp = OpenID::SReg::Response.from_success_response(oidresp)
236
+ sreg_resp = OpenID::SReg::Response.from_success_response(oidresp)
237
237
  sreg_message = "Simple Registration data was requested"
238
238
  if sreg_resp.empty?
239
239
  sreg_message << ", but none was returned."
@@ -247,7 +247,7 @@ module Appoxy
247
247
  puts sreg_message
248
248
  end
249
249
  if params[:did_pape]
250
- pape_resp = OpenID::PAPE::Response.from_success_response(oidresp)
250
+ pape_resp = OpenID::PAPE::Response.from_success_response(oidresp)
251
251
  pape_message = "A phishing resistant authentication method was requested"
252
252
  if pape_resp.auth_policies.member? OpenID::PAPE::AUTH_PHISHING_RESISTANT
253
253
  pape_message << ", and the server reported one."
@@ -294,14 +294,14 @@ module Appoxy
294
294
  def facebook_auth(app_id, app_secret, options={})
295
295
  p params
296
296
  redirect_uri = options[:redirect_uri] || "#{base_url}/sessions/create_facebook"
297
- code = params['code'] # Facebooks verification string
297
+ code = params['code'] # Facebooks verification string
298
298
  if code
299
299
  access_token_hash = MiniFB.oauth_access_token(app_id,
300
300
  redirect_uri,
301
301
  app_secret,
302
302
  code)
303
303
  # p access_token_hash
304
- @access_token = access_token_hash["access_token"]
304
+ @access_token = access_token_hash["access_token"]
305
305
  unless @access_token
306
306
  flash[:warning] = "Authentication did not work, no access_token"
307
307
  redirect_to :action=>"new"
@@ -310,25 +310,25 @@ module Appoxy
310
310
 
311
311
  session[:access_token] = @access_token
312
312
 
313
- me = MiniFB.get(@access_token, "me")
313
+ me = MiniFB.get(@access_token, "me")
314
314
  puts 'me=' + me.inspect
315
- @user = User.find_by_fb_id(me.id)
315
+ @user = User.find_by_fb_id(me.id)
316
316
  new_user = @user.nil?
317
317
  if new_user
318
- @user = User.create(:fb_id =>me.id,
319
- :email =>me.email,
320
- :first_name =>me.first_name,
321
- :last_name =>me.last_name,
318
+ @user = User.create(:fb_id =>me.id,
319
+ :email =>me.email,
320
+ :first_name =>me.first_name,
321
+ :last_name =>me.last_name,
322
322
  :fb_access_token=>@access_token,
323
- :status =>"active")
323
+ :status =>"active")
324
324
 
325
325
 
326
326
  else
327
- @user.email = me.email
327
+ @user.email = me.email
328
328
  @user.fb_access_token = @access_token
329
- @user.first_name = me.first_name
330
- @user.last_name = me.last_name
331
- @user.status = "active"
329
+ @user.first_name = me.first_name
330
+ @user.last_name = me.last_name
331
+ @user.status = "active"
332
332
  # @user.fake = false
333
333
  @user.save(:dirty=>true)
334
334
  end
@@ -338,31 +338,33 @@ module Appoxy
338
338
  end
339
339
  end
340
340
 
341
- def oauth_start(key, secret, callback_url, site, request_token_path, authorize_path, access_token_path)
342
- consumer = oauth_consumer(key, secret,
343
- callback_url,
344
- site,
345
- request_token_path,
346
- authorize_path,
347
- access_token_path
341
+
342
+ def oauth_start(key, secret, callback_url, site, request_token_path, authorize_path, access_token_path, options={})
343
+ consumer = oauth_consumer(key, secret,
344
+ callback_url,
345
+ site,
346
+ request_token_path,
347
+ authorize_path,
348
+ access_token_path,
349
+ options
348
350
  )
349
- @request_token = consumer.get_request_token(:oauth_callback => callback_url)
351
+ @request_token = consumer.get_request_token(:oauth_callback => callback_url)
350
352
  session[:request_token] = @request_token
351
- auth_url = @request_token.authorize_url(:oauth_callback => callback_url)
353
+ auth_url = @request_token.authorize_url(:oauth_callback => callback_url)
352
354
  puts auth_url.inspect
353
355
  redirect_to auth_url
354
356
  end
355
357
 
356
358
  def twitter_auth
357
- signin = true
358
- callback_url = "#{base_url}/sessions/#{(signin ? "create_twitter" : "create_twitter_oauth")}"
359
- auth_path = signin ? "authenticate" : "authorize"
360
- consumer = oauth_start(::Rails.application.config.twitter_consumer_key, Rails.application.config.twitter_consumer_secret,
361
- callback_url,
362
- "https://rails.twitter.com",
363
- "/oauth/request_token",
364
- "/oauth/#{auth_path}",
365
- "/oauth/access_token"
359
+ signin = true
360
+ callback_url = "#{base_url}/sessions/#{(signin ? "create_twitter" : "create_twitter_oauth")}"
361
+ auth_path = signin ? "authenticate" : "authorize"
362
+ consumer = oauth_start(::Rails.application.config.twitter_consumer_key, Rails.application.config.twitter_consumer_secret,
363
+ callback_url,
364
+ "https://rails.twitter.com",
365
+ "/oauth/request_token",
366
+ "/oauth/#{auth_path}",
367
+ "/oauth/access_token"
366
368
  )
367
369
  end
368
370
 
@@ -370,24 +372,24 @@ module Appoxy
370
372
  def create_twitter_oauth
371
373
  puts 'params=' + params.inspect
372
374
  @request_token = session[:request_token]
373
- @access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
375
+ @access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
374
376
  puts 'access_token = ' + @access_token.inspect
375
377
 
376
378
  token = OauthToken.find_by_user_id_and_site_and_type(current_user.id, @access_token.consumer(:signin=>true).site, "access")
377
379
  puts 'found token? ' + token.inspect
378
380
  unless token
379
- token = OauthToken.new(:type =>"access",
380
- :user =>current_user,
381
- :site =>@access_token.consumer.site,
381
+ token = OauthToken.new(:type =>"access",
382
+ :user =>current_user,
383
+ :site =>@access_token.consumer.site,
382
384
  :token =>@access_token.token,
383
385
  :secret=>@access_token.secret)
384
386
  token.save!
385
387
  else
386
- token.token = @access_token.token
388
+ token.token = @access_token.token
387
389
  token.secret = @access_token.secret
388
390
  token.save(:dirty=>true)
389
391
  end
390
- @token = token
392
+ @token = token
391
393
 
392
394
  flash[:success] = "Authorized with Twitter."
393
395
 
@@ -395,7 +397,7 @@ module Appoxy
395
397
 
396
398
  def get_oauth_access_token
397
399
  @request_token = session[:request_token]
398
- @access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
400
+ @access_token = @request_token.get_access_token(:oauth_verifier => params[:oauth_verifier])
399
401
  puts 'access_token = ' + @access_token.inspect
400
402
  p @access_token.params
401
403
  @access_token
@@ -410,7 +412,7 @@ module Appoxy
410
412
  unless @user
411
413
  @user = User.new(# shouldn't set this, because can't say it will be unique ':username =>@access_token.params[:screen_name],
412
414
  :twitter_screen_name=>@access_token.params[:screen_name],
413
- :twitter_id =>@access_token.params[:user_id])
415
+ :twitter_id =>@access_token.params[:user_id])
414
416
  @user.set_remember
415
417
  @user.save
416
418
  puts '@user=' + @user.inspect
@@ -482,14 +484,18 @@ module Appoxy
482
484
  end
483
485
 
484
486
 
485
- def oauth_consumer(key, secret, callback, site, request_token_path, authorize_path, access_token_path)
487
+ def oauth_consumer(key, secret, callback, site, request_token_path, authorize_path, access_token_path, options={})
488
+ params = {:site => site,
489
+ :oauth_callback => callback,
490
+ :request_token_path => request_token_path,
491
+ :authorize_path => authorize_path,
492
+ :access_token_path => access_token_path}
493
+ params[:signature_method] = options[:signature_method] if options[:signature_method]
494
+ params[:scheme] = options[:scheme] if options[:scheme]
495
+
486
496
  @consumer = OAuth::Consumer.new(key,
487
497
  secret,
488
- :site => site,
489
- :oauth_callback => callback,
490
- :request_token_path => request_token_path,
491
- :authorize_path => authorize_path,
492
- :access_token_path => access_token_path)
498
+ params)
493
499
  p @consumer
494
500
  @consumer
495
501
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appoxy_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-02-19 00:00:00.000000000 -08:00
12
+ date: 2011-03-02 00:00:00.000000000 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
17
- requirement: &23651196 !ruby/object:Gem::Requirement
17
+ requirement: &22911948 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *23651196
25
+ version_requirements: *22911948
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: oauth
28
- requirement: &23650908 !ruby/object:Gem::Requirement
28
+ requirement: &22911588 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *23650908
36
+ version_requirements: *22911588
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: ruby-openid
39
- requirement: &23650620 !ruby/object:Gem::Requirement
39
+ requirement: &22911228 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *23650620
47
+ version_requirements: *22911228
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: appoxy_api
50
- requirement: &23650332 !ruby/object:Gem::Requirement
50
+ requirement: &22730196 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *23650332
58
+ version_requirements: *22730196
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: mini_fb
61
- requirement: &23650044 !ruby/object:Gem::Requirement
61
+ requirement: &22717308 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *23650044
69
+ version_requirements: *22717308
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: simple_record
72
- requirement: &23649756 !ruby/object:Gem::Requirement
72
+ requirement: &22716300 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :runtime
79
79
  prerelease: false
80
- version_requirements: *23649756
80
+ version_requirements: *22716300
81
81
  description: Appoxy API Helper gem description...
82
82
  email: travis@appoxy.com
83
83
  executables: []
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  requirements: []
128
128
  rubyforge_project:
129
- rubygems_version: 1.5.2
129
+ rubygems_version: 1.6.0
130
130
  signing_key:
131
131
  specification_version: 3
132
132
  summary: Appoxy Rails Helper gem