Skip to content
This repository was archived by the owner on Aug 14, 2018. It is now read-only.

Commit 019fa9a

Browse files
Fining error where non experts users wereen't blocked
1 parent a4f6771 commit 019fa9a

File tree

1 file changed

+48
-3
lines changed

1 file changed

+48
-3
lines changed

src/experts-signin.html

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<link rel="import" href="../bower_components/iron-signals/iron-signals.html">
22

3+
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
4+
35
<link rel="import" href="../bower_components/google-signin/google-signin.html">
46

57
<!--
@@ -20,6 +22,16 @@
2022
label-signin="SIGN IN WITH GOOGLE"
2123
on-google-signed-out="_signedOut"></google-signin>
2224

25+
<iron-ajax
26+
id = "getAccountRequest"
27+
url = "https://elite-firefly-737.appspot.com/_ah/api/expertstracking/v2.0/account/{{_googleUser.email}}"
28+
method = "GET"
29+
handle-as = "json"
30+
last-response = "{{_apiUser}}"
31+
on-response = "_handleAccountInfo"
32+
on-error = "_handleAccountError">
33+
</iron-ajax>
34+
2335
</template>
2436

2537
<script>
@@ -51,8 +63,14 @@
5163
* User information from Google authentication
5264
*/
5365
_googleUser: {
66+
type: Object
67+
},
68+
69+
/**
70+
* User information from Google authentication
71+
*/
72+
_apiUser: {
5473
type: Object,
55-
observer: '_userInfoChanged'
5674
},
5775

5876
/**
@@ -91,7 +109,8 @@
91109

92110
console.debug("[experts-signin] _signedIn",this._googleUser);
93111

94-
this.fire('iron-signal', {name: 'user', data: this._googleUser} )
112+
this.$.getAccountRequest.generateRequest();
113+
95114
},
96115

97116
/**
@@ -137,7 +156,33 @@
137156
*/
138157
_computeAuthorized: function (user) {
139158
return (!!user && !!user.email);
140-
}
159+
},
160+
161+
_handleAccountInfo: function(evt, ironRequest) {
162+
console.debug("[experts-profile] _handleAccountInfo - apiUser",this._apiUser);
163+
evt.stopPropagation();
164+
var user = this._googleUser;
165+
if (this._apiUser && this._apiUser.email) {
166+
if (this._apiUser.expert_type) {
167+
user.category = this._apiUser.expert_type;
168+
user.isExpert = (this._apiUser.expert_type !== 'deleted');
169+
}
170+
user.skills = this._apiUser.skills;
171+
user.biography = this._apiUser.biography;
172+
user.city = this._apiUser.city;
173+
user.country = this._apiUser.country;
174+
if (this._apiUser.pic_url) {
175+
user.image = this._apiUser.pic_url;
176+
}
177+
user.product_group = this._apiUser.product_group;
178+
}
179+
this._setUser(user);
180+
console.debug("[experts-profile] _handleAccountInfo", this.user);
181+
this.fire('iron-signal', {name: 'user', data: this.user} )
182+
},
183+
_handleAccountError: function(evt, error) {
184+
185+
},
141186
});
142187
})();
143188
</script>

0 commit comments

Comments
 (0)