exvo-auth 0.10.4 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- exvo-auth (0.10.3)
4
+ exvo-auth (0.11.0)
5
5
  actionpack (~> 3.0.0)
6
6
  activemodel (~> 3.0.0)
7
7
  httparty (~> 0.6.1)
data/README CHANGED
@@ -44,13 +44,7 @@ Sample implementation (Rails):
44
44
 
45
45
  class SessionsController < ApplicationController
46
46
  def create
47
- auth = params[:auth] # sometimes you will need to do this: request.env["rack.request.query_hash"]["auth"]
48
- user = User.find_or_create_by_uid(auth["uid"])
49
-
50
- user_info = auth["user_info"]
51
- user.update_attributes!(user_info)
52
-
53
- sign_in_and_redirect!(user.id)
47
+ sign_in_and_redirect!
54
48
  end
55
49
 
56
50
  def destroy
@@ -61,11 +55,19 @@ class SessionsController < ApplicationController
61
55
  render :text => "Sorry!"
62
56
  end
63
57
  end
58
+
59
+
60
+ 6. Implement #find_or_create_user_by_uid(uid) in your Application Controller.
61
+
62
+ This method will be called by #current_user. Previously we did this in sessions_controller but since the sharing sessions changes this controller
63
+ will not be used in most cases because the session comes from another app through a shared cookie. This method should find user by uid or create it.
64
+ Additional info (emails, etc) can be obtained using auth api (/users/uid.json path).
65
+
64
66
 
65
67
  In short: you get params[:auth]. Do what you want to do with it: store the data, create session, etc.
66
68
 
67
69
 
68
- 6. Sign up and sign in paths for use in links.
70
+ 7. Sign up and sign in paths for use in links.
69
71
 
70
72
  sign in path: "/auth/interactive"
71
73
  sign up path: "/auth/interactive?x_sign_up=true" # this is OAuth2 custom param
@@ -74,7 +76,7 @@ sign in path with a return address: "/auth/interactive?state=url" # using O
74
76
  You have a handy methods available in controllers (and views in Rails): sign_in_path and sign_up_path.
75
77
 
76
78
 
77
- 7. Read the source, there are few features not mentioned in this README.
79
+ 8. Read the source, there are few features not mentioned in this README.
78
80
 
79
81
 
80
82
  Inter-Application Communication
@@ -16,8 +16,8 @@ module ExvoAuth::Controllers::Base
16
16
  end
17
17
 
18
18
  # Usually this method is called from your sessions#create.
19
- def sign_in_and_redirect!(user_id)
20
- session[:user_id] = user_id
19
+ def sign_in_and_redirect!
20
+ session[:user_id] = request.env["rack.request.query_hash"]["auth"]["uid"]
21
21
 
22
22
  url = if params[:state] == "popup"
23
23
  ExvoAuth::Config.host + "/close_popup.html"
@@ -63,7 +63,7 @@ module ExvoAuth::Controllers::Base
63
63
 
64
64
  def current_user
65
65
  return @current_user if defined?(@current_user)
66
- @current_user = session[:user_id] && find_user_by_id(session[:user_id])
66
+ @current_user = session[:user_id] && find_or_create_user_by_uid(session[:user_id])
67
67
  end
68
68
 
69
69
  def current_app_id
@@ -73,8 +73,12 @@ module ExvoAuth::Controllers::Base
73
73
  def signed_in?
74
74
  !!current_user
75
75
  end
76
-
76
+
77
77
  protected
78
+
79
+ def find_or_create_user_by_uid(uid)
80
+ raise "Implement this method in a controller"
81
+ end
78
82
 
79
83
  def sign_out_url(return_to)
80
84
  ExvoAuth::Config.host + "/users/sign_out?" + Rack::Utils.build_query({ :return_to => return_to })
@@ -23,9 +23,5 @@ module ExvoAuth::Controllers::Merb
23
23
  def redirect_to(*args)
24
24
  redirect(*args)
25
25
  end
26
-
27
- def find_user_by_id(id)
28
- User[id]
29
- end
30
26
  end
31
27
  end
@@ -15,9 +15,5 @@ module ExvoAuth::Controllers::Rails
15
15
  def basic_authentication_method_name
16
16
  :authenticate_or_request_with_http_basic
17
17
  end
18
-
19
- def find_user_by_id(id)
20
- User.find(id)
21
- end
22
18
  end
23
19
  end
@@ -1,3 +1,3 @@
1
1
  module ExvoAuth
2
- VERSION = "0.10.4"
2
+ VERSION = "0.11.0"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exvo-auth
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 51
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 10
9
- - 4
10
- version: 0.10.4
8
+ - 11
9
+ - 0
10
+ version: 0.11.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jacek Becela