exvo-auth 0.10.4 → 0.11.0
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/Gemfile.lock +1 -1
- data/README +11 -9
- data/lib/exvo_auth/controllers/base.rb +8 -4
- data/lib/exvo_auth/controllers/merb.rb +0 -4
- data/lib/exvo_auth/controllers/rails.rb +0 -4
- data/lib/exvo_auth/version.rb +1 -1
- metadata +4 -4
data/Gemfile.lock
CHANGED
data/README
CHANGED
@@ -44,13 +44,7 @@ Sample implementation (Rails):
|
|
44
44
|
|
45
45
|
class SessionsController < ApplicationController
|
46
46
|
def create
|
47
|
-
|
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
|
-
|
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
|
-
|
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!
|
20
|
-
session[: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] &&
|
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 })
|
data/lib/exvo_auth/version.rb
CHANGED
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:
|
4
|
+
hash: 51
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 11
|
9
|
+
- 0
|
10
|
+
version: 0.11.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jacek Becela
|