pp_login 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.
- checksums.yaml +4 -4
- data/app/controllers/pp_login/application_controller.rb +3 -0
- data/app/controllers/pp_login/pp_account_controller.rb +6 -18
- data/lib/pp_login/engine.rb +4 -0
- data/lib/pp_login/main/modules/account_actions.rb +9 -13
- data/lib/pp_login/main/modules/helpers.rb +44 -22
- data/lib/pp_login/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 400e72f1eb22bdc43381e5fdc80f7303c9aba24c
|
4
|
+
data.tar.gz: e182b04da2d4ee96539a6924cf09e640d6612a6d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2900e950bade950ea119724d515d9b20c1df3384824a844471b70c9dad43d57dd80127c22e491cc47e297bd5de17e6465340dc59787ab2fdff244d427229849
|
7
|
+
data.tar.gz: 4877f97241b7b3eb295f5fc69023c1179547234b0939eaad654a8c658adc013ef2cd19830dd49a222b5d75a8d4f4f95333a1cc86d63760be9b5039560c744c58
|
@@ -1,23 +1,23 @@
|
|
1
1
|
module PpLogin
|
2
|
-
class
|
2
|
+
class PpAccountController < ApplicationController
|
3
3
|
|
4
4
|
def get_token
|
5
|
-
token =
|
5
|
+
token = get_access_token(token_params[:code])
|
6
6
|
save_info(token)
|
7
7
|
end
|
8
8
|
|
9
9
|
def refresh_token
|
10
|
-
token =
|
10
|
+
token = refresh_token(token_params[:refresh_token])
|
11
11
|
save_info(token)
|
12
12
|
end
|
13
13
|
|
14
14
|
def user_info
|
15
|
-
user_info =
|
15
|
+
user_info = get_user_info(token_params[:access_token])
|
16
16
|
save_info(user_info)
|
17
17
|
end
|
18
18
|
|
19
19
|
def logout
|
20
|
-
token =
|
20
|
+
token = refresh_token(token_params[:refresh_token])
|
21
21
|
redirect_to token.logout_url
|
22
22
|
end
|
23
23
|
|
@@ -26,18 +26,6 @@ module PpLogin
|
|
26
26
|
{ token_type: params[:token_type] ,expires_in: params[:expires_in] ,refresh_token: params[:refresh_token] ,access_token: params[:access_token], code: params[:code] }
|
27
27
|
end
|
28
28
|
|
29
|
-
def for_action
|
30
|
-
@to_return ||= begin
|
31
|
-
case(action_name)
|
32
|
-
when 'get_token', 'refresh_token'
|
33
|
-
return {store: PpLogin.token_store, type: :token}
|
34
|
-
when 'user_info'
|
35
|
-
return {store: PpLogin.user_store, type: :user}
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
29
|
def save_info(info)
|
42
30
|
case(for_action[:store])
|
43
31
|
when :param
|
@@ -55,4 +43,4 @@ module PpLogin
|
|
55
43
|
|
56
44
|
end
|
57
45
|
end
|
58
|
-
end
|
46
|
+
end
|
data/lib/pp_login/engine.rb
CHANGED
@@ -1,19 +1,15 @@
|
|
1
1
|
module PpLogin
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
return Tokeninfo.create(code)
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.refresh_token(refresh_token)
|
10
|
-
return Tokeninfo.refresh(refresh_token)
|
11
|
-
end
|
3
|
+
def self.get_access_token(code)
|
4
|
+
return Engine.instance_exec(code){|c| return self::Tokeninfo.create(c) }
|
5
|
+
end
|
12
6
|
|
13
|
-
|
14
|
-
|
15
|
-
|
7
|
+
def self.refresh_token(refresh_token)
|
8
|
+
return Engine.instance_exec(refresh_token){|rt| self::Tokeninfo.refresh(rt) }
|
9
|
+
end
|
16
10
|
|
11
|
+
def self.get_user_info(access_token)
|
12
|
+
return Engine.instance_exec(get_access_token){|at| self::Userinfo.get(at) }
|
17
13
|
end
|
18
14
|
|
19
|
-
end
|
15
|
+
end
|
@@ -1,32 +1,54 @@
|
|
1
1
|
module PpLogin
|
2
2
|
module Helpers
|
3
3
|
def self.included(base)
|
4
|
-
base.send :helper_method, :user_info, :token
|
4
|
+
base.send :helper_method, :user_info, :token, :paypal_login
|
5
5
|
end
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
p 'This Method of saving is not yet implimented'
|
6
|
+
|
7
|
+
def for_action manual
|
8
|
+
@to_return ||= begin
|
9
|
+
case(manual || action_name)
|
10
|
+
when 'get_token', 'refresh_token'
|
11
|
+
return {store: PpLogin.token_store, type: :token}
|
12
|
+
when 'user_info'
|
13
|
+
return {store: PpLogin.user_store, type: :user}
|
14
|
+
end
|
16
15
|
end
|
17
16
|
end
|
18
17
|
|
18
|
+
def user_info
|
19
|
+
get_info('get_token')
|
20
|
+
end
|
21
|
+
|
22
|
+
|
23
|
+
|
19
24
|
def token
|
20
|
-
|
21
|
-
when :param
|
22
|
-
JSON.parse(params[:token])
|
23
|
-
when :session
|
24
|
-
JSON.parse(session[:token])
|
25
|
-
when :cookie
|
26
|
-
JSON.parse(cookies[:token])
|
27
|
-
when :db
|
28
|
-
p 'This Method of saving is not yet implimented'
|
29
|
-
end
|
25
|
+
get_info('get_token')
|
30
26
|
end
|
27
|
+
|
28
|
+
def paypal_login type, prop={}
|
29
|
+
self.instance_exec(type,prop) do |type,prop|
|
30
|
+
case(type)
|
31
|
+
when :link
|
32
|
+
link_to prop[:text]||'Login With PayPal',PpLogin.loginURL, prop
|
33
|
+
when :button
|
34
|
+
button_to prop[:text]||'Login With PayPal',PpLogin.loginURL, prop
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def get_info(kind)
|
42
|
+
case(for_action(kind)[:store])
|
43
|
+
when :param
|
44
|
+
JSON.parse(params[for_action[:type]])
|
45
|
+
when :session
|
46
|
+
JSON.parse(session[for_action[:type]])
|
47
|
+
when :cookie
|
48
|
+
JSON.parse(cookies[for_action[:type]])
|
49
|
+
when :db
|
50
|
+
p 'This Method of saving is not yet implimented'
|
51
|
+
end
|
52
|
+
end
|
31
53
|
end
|
32
|
-
end
|
54
|
+
end
|
data/lib/pp_login/version.rb
CHANGED