ishapi 0.1.8.57 → 0.1.8.58
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/addresses_controller.rb +23 -0
- data/app/controllers/ishapi/application_controller.rb +25 -9
- data/app/controllers/ishapi/users_controller.rb +6 -4
- data/app/models/ishapi/ability.rb +8 -0
- data/app/views/ishapi/addresses/_show.jbuilder +12 -0
- data/app/views/ishapi/users/show.jbuilder +14 -9
- data/config/initializers/koala.rb +2 -2
- data/config/routes.rb +2 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6c92b67c14e6c55592bdc128aa289ff60ed361b2
|
4
|
+
data.tar.gz: 735a14c7f9fa8f8d2b7b225fc55c7e91ab9da436
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0ad0e81ca3aa3202f03c7fa80ffed7c6d94dd02fb8e4b16fc9276e6ff745faf0cc499390225cbe38d9204df2130344fb9000b4620f12fda7b2ec9d6212e79d7
|
7
|
+
data.tar.gz: af92344d2edc48c8e508599a6521e9b042a26dffcca5ef7b0f806a13ad7b582daa2e395243cba11c688a9ebf9358f6c34da3c63fea384cdb724401baada2c114
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require_dependency "ishapi/application_controller"
|
2
|
+
|
3
|
+
module Ishapi
|
4
|
+
class AddressesController < ApplicationController
|
5
|
+
before_action :check_profile, :only => [ :create ]
|
6
|
+
|
7
|
+
def create
|
8
|
+
if @current_profile.addresses.length == 0
|
9
|
+
@address = CoTailors::Address.new({ :profile_id => @current_profile.id })
|
10
|
+
else
|
11
|
+
@address = @current_profile.addresses[0]
|
12
|
+
end
|
13
|
+
authorize! :update, @address
|
14
|
+
flag = @address.update_attributes( params[:address].permit(:name, :phone, :address_1, :address_2, :city, :state, :zipcode ) )
|
15
|
+
if flag
|
16
|
+
render :json => { :status => :ok, :message => 'Successfully put an address.' }
|
17
|
+
else
|
18
|
+
render :json => { :status => :not_ok, :error => @address.errors.messages }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -11,6 +11,19 @@ module Ishapi
|
|
11
11
|
#
|
12
12
|
private
|
13
13
|
|
14
|
+
# this doesn't generate long-lived token, doesn't update user_profile
|
15
|
+
def check_profile
|
16
|
+
accessToken = request.headers[:accessToken]
|
17
|
+
accessToken ||= params[:fb_long_access_token]
|
18
|
+
accessToken ||= params[:accessToken] # if (params[:debug] == 'abba' && Rails.env.development?)
|
19
|
+
if accessToken
|
20
|
+
@graph = Koala::Facebook::API.new( accessToken )
|
21
|
+
@me = @graph.get_object( 'me', :fields => 'email' )
|
22
|
+
@current_user = User.find_by :email => @me['email']
|
23
|
+
@current_profile = @current_user.profile
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
14
27
|
def set_profile
|
15
28
|
accessToken = request.headers[:accessToken]
|
16
29
|
accessToken ||= params[:fb_long_access_token]
|
@@ -24,19 +37,23 @@ module Ishapi
|
|
24
37
|
@me = @graph.get_object( 'me', :fields => 'email' )
|
25
38
|
@user = User.find_or_create_by :email => @me['email']
|
26
39
|
@oauth = Koala::Facebook::OAuth.new( FB[params['domain']][:app], FB[params['domain']][:secret] )
|
27
|
-
|
40
|
+
get_token = get_long_token( accessToken )
|
41
|
+
@long_lived_token = get_token['access_token']
|
28
42
|
|
29
43
|
begin
|
30
44
|
@profile = IshModels::UserProfile.find_by :email => @me['email']
|
31
45
|
@profile.update_attributes({ :fb_access_token => @long_lived_token,
|
32
|
-
:fb_long_access_token => @long_lived_token
|
46
|
+
:fb_long_access_token => @long_lived_token,
|
47
|
+
:fb_expires_in => get_token['expires_in']
|
48
|
+
})
|
33
49
|
rescue Mongoid::Errors::DocumentNotFound
|
34
50
|
@profile = IshModels::UserProfile.create :user => @user, :email => @me['email'],
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
51
|
+
:fb_access_token => @long_lived_token,
|
52
|
+
:fb_long_access_token => @long_lived_token,
|
53
|
+
:fb_expires_in => get_token['expires_in'],
|
54
|
+
:fb_id => params[:id],
|
55
|
+
:name => params[:name],
|
56
|
+
:signed_request => params[:signedRequest]
|
40
57
|
end
|
41
58
|
@current_user = @user
|
42
59
|
@current_profile = @profile
|
@@ -52,8 +69,7 @@ module Ishapi
|
|
52
69
|
"client_id=#{FB[params['domain']][:app]}&client_secret=#{FB[params['domain']][:secret]}&fb_exchange_token=#{accessToken}"
|
53
70
|
result = HTTParty.get url
|
54
71
|
token = JSON.parse result.body
|
55
|
-
|
56
|
-
return token['access_token']
|
72
|
+
return token # ['access_token']
|
57
73
|
end
|
58
74
|
|
59
75
|
def set_current_ability
|
@@ -2,16 +2,17 @@ require_dependency "ishapi/application_controller"
|
|
2
2
|
|
3
3
|
module Ishapi
|
4
4
|
class UsersController < ApplicationController
|
5
|
-
|
6
5
|
before_action :set_profile, :only => [ :fb_sign_in, :show ]
|
7
6
|
|
8
7
|
def fb_sign_in
|
9
8
|
authorize! :fb_sign_in, Ishapi
|
10
|
-
render :json => { :status => :ok }
|
9
|
+
# render :json => { :status => :ok }
|
10
|
+
render :action => 'show'
|
11
11
|
end
|
12
12
|
|
13
13
|
def show
|
14
14
|
authorize! :fb_sign_in, Ishapi
|
15
|
+
=begin
|
15
16
|
begin
|
16
17
|
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
17
18
|
me = @graph.get_object( 'me', :fields => 'email' )
|
@@ -21,11 +22,12 @@ module Ishapi
|
|
21
22
|
render :json => { :status => :not_ok, :errors => "Probably expired token." }
|
22
23
|
return
|
23
24
|
end
|
25
|
+
=end
|
24
26
|
end
|
25
27
|
|
28
|
+
=begin
|
26
29
|
def update
|
27
30
|
authorize! :fb_sign_in, Ishapi
|
28
|
-
|
29
31
|
begin
|
30
32
|
@graph = Koala::Facebook::API.new( params[:accessToken] )
|
31
33
|
me = @graph.get_object( 'me', :fields => 'email' )
|
@@ -37,13 +39,13 @@ module Ishapi
|
|
37
39
|
flag = false
|
38
40
|
@errors = "Probably expired token."
|
39
41
|
end
|
40
|
-
|
41
42
|
if flag
|
42
43
|
render :json => { :status => :ok }
|
43
44
|
else
|
44
45
|
render :json => { :status => :not_ok, :errors => @errors }
|
45
46
|
end
|
46
47
|
end
|
48
|
+
=end
|
47
49
|
|
48
50
|
end
|
49
51
|
end
|
@@ -16,6 +16,12 @@ class Ishapi::Ability
|
|
16
16
|
can [ :show ], Gallery do |gallery|
|
17
17
|
gallery.user == user
|
18
18
|
end
|
19
|
+
|
20
|
+
|
21
|
+
can [ :update ], CoTailors::Address do |address|
|
22
|
+
puts [ user.inspect, address.inspect ], '+++ user in cancancan'
|
23
|
+
true
|
24
|
+
end
|
19
25
|
|
20
26
|
end
|
21
27
|
#
|
@@ -24,6 +30,8 @@ class Ishapi::Ability
|
|
24
30
|
user ||= User.new
|
25
31
|
|
26
32
|
can [ :index, :show ], City
|
33
|
+
|
34
|
+
can [ :update ], CoTailors::Address
|
27
35
|
|
28
36
|
can [ :index, :show ], Event
|
29
37
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
|
2
|
+
# ishapi / addresses / _show
|
3
|
+
|
4
|
+
json.address do
|
5
|
+
json.name address.name
|
6
|
+
json.phone address.phone
|
7
|
+
json.address_1 address.address_1
|
8
|
+
json.address_2 address.address_2
|
9
|
+
json.city address.city
|
10
|
+
json.state address.state
|
11
|
+
json.zipcode address.zipcode
|
12
|
+
end
|
@@ -3,13 +3,18 @@
|
|
3
3
|
# ishapi / users / _show.jbuilder
|
4
4
|
#
|
5
5
|
|
6
|
-
json.email @
|
7
|
-
json.about @
|
8
|
-
json.lang @
|
9
|
-
json.name @
|
10
|
-
json.fb_long_access_token @
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
json.
|
6
|
+
json.email @current_profile.email
|
7
|
+
json.about @current_profile.about
|
8
|
+
json.lang @current_profile.lang
|
9
|
+
json.name @current_profile.name
|
10
|
+
json.fb_long_access_token @current_profile.fb_long_access_token
|
11
|
+
json.expires_in @current_profile.fb_expires_in
|
12
|
+
|
13
|
+
if @current_profile.current_city
|
14
|
+
json.current_city_id @current_profile.current_city_id.to_s
|
15
|
+
json.current_city @current_profile.current_city
|
16
|
+
end
|
17
|
+
|
18
|
+
if @current_profile.addresses[0]
|
19
|
+
json.partial! 'ishapi/addresses/show', :address => @current_profile.addresses[0]
|
15
20
|
end
|
data/config/routes.rb
CHANGED
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.58
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- piousbox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-01-
|
11
|
+
date: 2018-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- app/assets/stylesheets/ishapi/application.css
|
167
167
|
- app/assets/stylesheets/ishapi/articles.css
|
168
168
|
- app/assets/stylesheets/scaffold.css
|
169
|
+
- app/controllers/ishapi/addresses_controller.rb
|
169
170
|
- app/controllers/ishapi/api_controller.rb
|
170
171
|
- app/controllers/ishapi/api_controller.rb~
|
171
172
|
- app/controllers/ishapi/application_controller.rb
|
@@ -201,6 +202,7 @@ files:
|
|
201
202
|
- app/models/ishapi/ability.rb~
|
202
203
|
- app/models/ishapi/application_record.rb
|
203
204
|
- app/models/ishapi/article.rb
|
205
|
+
- app/views/ishapi/addresses/_show.jbuilder
|
204
206
|
- app/views/ishapi/application/_meta.jbuilder
|
205
207
|
- app/views/ishapi/application/_meta.jbuilder~
|
206
208
|
- app/views/ishapi/articles/_form.html.erb
|