ishapi 0.1.8.112 → 0.1.8.113
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/ishapi/application_controller.rb +54 -2
- data/app/models/ishapi/ability.rb +1 -1
- data/config/routes.rb +5 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4637596e6a37543fa475080036de6cf6608819bdec649a8f532dbfd41d2cef9
|
4
|
+
data.tar.gz: cd7efda397b67a7aca5c8367aa5bd99868d9a125667ed00ad3bdaa6e341ece89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e09846934b8b8ef8e8313a8901eab92ffc3bb4e02c355da51c575f9b61a6118e28a2b6babf8e4963658988161ac33ab167b02bcad02014c71b9ba182e2ba55c
|
7
|
+
data.tar.gz: 2acd4ace8859d8a1b787f45fc58596330287e8d50391c766afd528fad03cc25243da82dcf0e7cb7d084aa9f439662261393d79e868ae3262c355abfaa933417c
|
@@ -1,5 +1,7 @@
|
|
1
1
|
module Ishapi
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
+
after_action :append_long_term_token, except: [ :long_term_token, :test ]
|
4
|
+
|
3
5
|
protect_from_forgery :prepend => true, :with => :exception
|
4
6
|
layout :false
|
5
7
|
|
@@ -12,11 +14,36 @@ module Ishapi
|
|
12
14
|
def test
|
13
15
|
end
|
14
16
|
|
17
|
+
def long_term_token
|
18
|
+
authorize! :long_term_token, ::Ishapi
|
19
|
+
|
20
|
+
accessToken = request.headers[:accessToken]
|
21
|
+
accessToken ||= params[:accessToken]
|
22
|
+
|
23
|
+
params['domain'] = 'tgm.piousbox.com'
|
24
|
+
|
25
|
+
response = HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
26
|
+
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&" +
|
27
|
+
"fb_exchange_token=#{accessToken}"
|
28
|
+
j = JSON.parse response.body
|
29
|
+
@long_term_token = j['access_token']
|
30
|
+
|
31
|
+
render json: { long_term_token: @long_term_token }
|
32
|
+
end
|
33
|
+
|
15
34
|
#
|
16
35
|
# private
|
17
36
|
#
|
18
37
|
private
|
19
38
|
|
39
|
+
def append_long_term_token
|
40
|
+
puts! 'after action!', @long_term_token
|
41
|
+
|
42
|
+
if @long_term_token
|
43
|
+
response.body = JSON.parse(response.body).merge({ long_term_token: @long_term_token }).to_json
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
20
47
|
def check_multiprofile provider = 'google'
|
21
48
|
if 'google' == provider
|
22
49
|
# client_secrets = ::Google::APIClient::ClientSecrets.load
|
@@ -30,25 +57,50 @@ module Ishapi
|
|
30
57
|
@current_user = User.find_by email: decoded_token[0]['email']
|
31
58
|
|
32
59
|
elsif 'facebook' == provider
|
60
|
+
# accessToken ||= params[:fb_long_access_token]
|
61
|
+
|
33
62
|
accessToken = request.headers[:accessToken]
|
34
|
-
accessToken ||= params[:fb_long_access_token]
|
35
63
|
accessToken ||= params[:accessToken]
|
36
64
|
if accessToken
|
65
|
+
|
66
|
+
#
|
67
|
+
# long-term token
|
68
|
+
#
|
69
|
+
params['domain'] = 'tgm.piousbox.com'
|
70
|
+
puts! accessToken, 'accessToken'
|
71
|
+
response = HTTParty.get "https://graph.facebook.com/v5.0/oauth/access_token?grant_type=fb_exchange_token&" +
|
72
|
+
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&" +
|
73
|
+
"fb_exchange_token=#{accessToken}"
|
74
|
+
j = JSON.parse response.body
|
75
|
+
@long_term_token = j['access_token']
|
76
|
+
|
77
|
+
|
37
78
|
@graph = Koala::Facebook::API.new( accessToken )
|
38
79
|
@me = @graph.get_object( 'me', :fields => 'email' )
|
39
80
|
@current_user = User.where( :email => @me['email'] ).first
|
40
81
|
@current_user ||= User.create! email: @me['email'], password: SecureRandom.urlsafe_base64
|
41
|
-
|
82
|
+
|
42
83
|
@current_profile = @current_user.profile
|
43
84
|
if !@current_profile
|
85
|
+
begin
|
86
|
+
g = Gallery.find '5e1495e2d697f768ad0779eb'
|
87
|
+
rescue Mongoid::Errors::DocumentNotFound => e
|
88
|
+
g = Gallery.create id: '5e1495e2d697f768ad0779eb'
|
89
|
+
end
|
44
90
|
@current_profile = IshModels::UserProfile.create user: @current_user, name: @me['email'], email: @me['email']
|
45
91
|
test_newsitem = Newsitem.new gallery_id: '5e1495e2d697f768ad0779eb'
|
46
92
|
@current_profile.newsitems << test_newsitem
|
47
93
|
@current_profile.save
|
48
94
|
end
|
95
|
+
@current_profile.update fb_long_access_token: @long_term_token
|
49
96
|
else
|
50
97
|
@current_user = current_user if Rails.env.test?
|
51
98
|
end
|
99
|
+
|
100
|
+
puts! @current_user, 'current_user'
|
101
|
+
puts! @current_profile, 'current_profile'
|
102
|
+
# byebug
|
103
|
+
|
52
104
|
end
|
53
105
|
|
54
106
|
sign_in @current_user, scope: :user
|
data/config/routes.rb
CHANGED
@@ -55,10 +55,11 @@ Ishapi::Engine.routes.draw do
|
|
55
55
|
namespace :tgm do
|
56
56
|
end
|
57
57
|
|
58
|
-
post
|
59
|
-
post
|
60
|
-
post
|
61
|
-
get
|
58
|
+
post 'users/fb_sign_in', :to => 'users#fb_sign_in'
|
59
|
+
post 'users/profile', :to => 'users#show'
|
60
|
+
post 'users/profile/update', :to => 'users#update'
|
61
|
+
get 'users/profile', :to => 'users#show' # @TODO: only for testing! accessToken must be hidden
|
62
|
+
match 'users/long_term_token', to: 'application#long_term_token', via: [ :get, :post ]
|
62
63
|
|
63
64
|
get 'venues', :to => 'venues#index'
|
64
65
|
get 'venues/view/:venuename', :to => 'venues#show'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ishapi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.8.
|
4
|
+
version: 0.1.8.113
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|