@widgetic/editor 3.10.41 → 3.10.43

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@widgetic/editor",
3
- "version": "3.10.41",
3
+ "version": "3.10.43",
4
4
  "scripts": {
5
5
  "start": "webpack --config webpack.config.js --watch --progress",
6
6
  "build": "webpack --config webpack.config.js",
@@ -51,12 +51,22 @@ class InstagramBrowser extends Controller
51
51
  # use the first one as the connected account
52
52
  # (there should be only one, but just in case)
53
53
  @authenticated = !!@content.length
54
+ console.log("Editor Instagram Browser @authenticated:", @authenticated, @content[0]);
54
55
  @el.attr {@authenticated}
55
56
  if @authenticated
56
57
  @connectedAccount = @content[0]
57
58
  # the content metadata stores the SHA256 hash of the user's Instagram token
58
59
  @service.getUser(@connectedAccount.token)
59
- .then((user) => this._updateLogoutIntent(user))
60
+ .then((user) =>
61
+ console.log("Editor Instagram Browser CT getUser result:", user)
62
+ if(user.error)
63
+ # console.log("Editor Browser get inst user result:", user)
64
+ # @onAuth(false);
65
+ this._updateLogoutIntent(@connectedAccount)
66
+ else
67
+ this._updateLogoutIntent(user)
68
+ )
69
+ .catch((err) => console.log("Editor Browser getUser err:", err))
60
70
 
61
71
  active: ->
62
72
  Activateable.active.apply @, arguments
@@ -69,12 +79,13 @@ class InstagramBrowser extends Controller
69
79
  Activateable.deactivate.apply @, arguments
70
80
 
71
81
  auth: (e) ->
82
+ console.log("Editor Instagram Browser auth handler:", e, @authenticated);
72
83
  return if @authenticated
73
84
  @service.auth( e?.type is 'click')
74
85
  true
75
86
 
76
87
  onAuth: (@authenticated) =>
77
- # console.log("Editor browser onAuth:", @authenticated)
88
+ console.log("Editor Instagram Browser onAuth:", @authenticated, @service.user)
78
89
  @el.attr {@authenticated}
79
90
  @$trigger "editor:browser:auth", service: @Service.name, @authenticated
80
91
  return unless @authenticated
@@ -88,6 +99,7 @@ class InstagramBrowser extends Controller
88
99
  item.type = 'user_id'
89
100
  item.id = @service.user.id
90
101
  item.url = 'Instagram User: @' + @service.user.username
102
+ item.username = @service.user.username
91
103
  @connectedAccount = item
92
104
  @trigger 'add', item
93
105
 
@@ -109,6 +121,7 @@ class InstagramBrowser extends Controller
109
121
  @tab.count @content.length
110
122
 
111
123
  _updateLogoutIntent: (user) ->
124
+ # console.log("update logout intent:", user)
112
125
  @logoutIntent.remove()
113
126
  @logoutIntent = $ LogoutIntent user
114
127
  @el.append @logoutIntent
@@ -1,7 +1,7 @@
1
1
  Service = require '../../../browser/model'
2
2
 
3
3
  # Instagram service config
4
- host = 'https://widgetic.com' + '/services/instagram'
4
+ host = 'https://widgetic.com' + '/services/instagram' #live server path
5
5
  INSTAGRAM_DEFAULTS = {
6
6
  client_id: '542808610040105', #widgetic instagram basic display app id
7
7
  client_secret: '0a88504381f577dbbef400d4232a4258',
@@ -18,9 +18,15 @@ INSTAGRAM_DEFAULTS = {
18
18
  }
19
19
  api = window.INSTAGRAM_SERVICE_CONFIG || INSTAGRAM_DEFAULTS
20
20
  # console.log("EDITOR Instagram API:", api);
21
+
22
+ # read current logged user's instagram auth token
21
23
  try api.token = localStorage.getItem 'instagramAuthToken'
24
+ console.log("Editor Instagram Service current user's token:", api.token);
25
+
26
+ # define auth url that will open in authorize popup
22
27
  auth_url = "https://api.instagram.com/oauth/authorize/?client_id=#{api.client_id}&redirect_uri=#{api.redirect_uri}&response_type=#{api.response_type}&scope=#{api.scope}"
23
28
 
29
+ # INSTAGRAM SERVICE CLASS
24
30
  class InstagramService extends Service
25
31
  @browser: 'browser/controller/instagram'
26
32
 
@@ -33,20 +39,22 @@ class InstagramService extends Service
33
39
  return api.token
34
40
 
35
41
  getUser: (token) ->
36
- url = "#{api.api_url}me"
42
+ # console.log("Editor Instagram Service getUser:", token, api.api_url);
43
+ url = "#{api.api_url}/me"
37
44
  $.ajax(url: url, type: 'GET', dataType: 'json', headers: {'X-Token': token})
38
45
 
39
46
  _auth: (interactive=true) ->
40
- # console.log("Editor ISTG service _auth method:", interactive, api);
47
+ console.log("Editor Instagram Service _auth method:", interactive, api.token);
41
48
  # if authenticated get user info to show it in the browser
42
49
  if api.token?
50
+ # console.log("Editor Instagram Service _auth method:", interactive, api.token);
43
51
  @getUser(api.token)
44
52
  .then (result) =>
45
- # console.log("Editor getUser result:", result)
53
+ console.log("Editor Instagram Service getUser result:", result)
46
54
  @user = result
47
55
  @trigger 'auth', @authenticated = true
48
56
  .catch =>
49
- # console.log("Editor getUser error:", error)
57
+ console.log("Editor Instagram Service getUser error:", error)
50
58
  @deauth()
51
59
  # console.log("Editor INSTG service _auth method:", interactive, api);
52
60
  # if not authenticated open popup