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

Commit efd1f4c

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

File tree

3 files changed

+142
-37
lines changed

3 files changed

+142
-37
lines changed

src/experts-app.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040

4141
<link rel="import" href="experts-icons.html">
4242
<link rel="import" href="experts-signin.html">
43+
<link rel="import" href="experts-not-logged-in.html">
44+
4345

4446
<script src="../bower_components/firebase/firebase.js"></script>
4547
<!--
@@ -214,7 +216,7 @@
214216
====================================
215217
-->
216218

217-
<iron-signals on-iron-signal-user="_userChanged"></iron-signals>
219+
<iron-signals on-iron-signal-user="_userSignalReceived"></iron-signals>
218220

219221
<app-location
220222
route = "{{route}}"
@@ -227,8 +229,8 @@
227229
tail = "{{subroute}}"></app-route>
228230

229231
<app-drawer-layout
230-
hidden$="{{!user}}"
231232
id = "drawer"
233+
hidden$="{{!user.ok}}"
232234
fullbleed>
233235
<app-drawer>
234236
<app-toolbar>
@@ -243,7 +245,7 @@
243245
role = "navigation"
244246
attr-for-selected = "name">
245247

246-
<template is="dom-if" if="{{user}}">
248+
<template is="dom-if" if="{{user.ok}}">
247249
<paper-button name="activities" on-click="_goToPage">
248250
Activities
249251
</paper-button>
@@ -356,16 +358,15 @@ <h1>Welcome!</h1>
356358
query-matches = "{{wideLayout}}">
357359
</iron-media-query>
358360

359-
<div id="not-signedin-container" hidden$="{{user}}" class="horizontal layout center-justified center-center">
360-
<paper-material id="not-signedin-hello">
361-
<img src="/images/gde-logo.svg">
362-
<h1>Welcome. Bienvenido. ようこそ.</h1>
363-
<p>Sign in to start logging your Google Expert activities.</p>
364-
<experts-signin user="{{user}}"></experts-signin>
365-
</paper-material>
361+
362+
<div
363+
id="not-signedin-container"
364+
hidden$="{{user.ok}}"
365+
class="horizontal layout center-justified center-center">
366+
<experts-not-logged-in
367+
id="userNotLoggedIn"
368+
user="{{user}}"></experts-not-logged-in>
366369
</div>
367-
368-
</template>
369370

370371
<firebase-collection
371372
location = "https://gooogle-experts-tracking-app.firebaseio.com/cache"
@@ -397,6 +398,7 @@ <h1>Welcome. Bienvenido. ようこそ.</h1>
397398
},
398399
user : {
399400
type : Object,
401+
observer: "_userChanged",
400402
value: null
401403
},
402404
_userSelected: {
@@ -407,8 +409,8 @@ <h1>Welcome. Bienvenido. ようこそ.</h1>
407409
observers : [
408410
'_routePageChanged(routeData.page)'
409411
],
410-
_userChanged: function(evt, user){
411-
console.debug("[experts-app] _userChanged ", user);
412+
_userSignalReceived: function(evt, user){
413+
console.debug("[experts-app] _userSignalReceived ", user);
412414
if (!user || !user.email) {
413415
this.user = false;
414416
return;

src/experts-not-logged-in.html

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<!--
2+
Google Developers Experts Tracking App
3+
Copyright (C) 2016 by the GDE Tracking App Team
4+
5+
gdetracking.appspot.com/
6+
https://github.com/GoogleDeveloperExperts/experts-app-web
7+
8+
This program is free software: you can redistribute it and/or modify
9+
it under the terms of the GNU General Public License as published by
10+
the Free Software Foundation, either version 3 of the License, or
11+
(at your option) any later version.
12+
13+
This program is distributed in the hope that it will be useful,
14+
but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16+
GNU General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License
19+
along with this program. If not, see <http://www.gnu.org/licenses/>
20+
-->
21+
<link rel="import" href="../bower_components/polymer/polymer.html">
22+
23+
<link rel="import" href="../bower_components/paper-material/paper-material.html">
24+
<link rel="import" href="../../bower_components/paper-dialog-behavior/paper-dialog-behavior.html">
25+
26+
<link rel="import" href="experts-signin.html">
27+
28+
<dom-module is="experts-not-logged-in">
29+
<!--
30+
====================================
31+
Shadow DOM
32+
====================================
33+
-->
34+
<template>
35+
<!--
36+
====================================
37+
CSS
38+
====================================
39+
-->
40+
<style>
41+
:host {
42+
width : 65vw;
43+
border-radius : 2px;
44+
background : white;
45+
transition : box-shadow 0.5s cubic-bezier(.25,.8,.25,1);
46+
box-shadow : 0 14px 28px rgba(0,0,0,0.25), 0 10px 10px rgba(0,0,0,0.22);
47+
font-family : Roboto;
48+
}
49+
:host:hover {
50+
box-shadow : 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22);
51+
}
52+
53+
paper-material {
54+
padding: 2em;
55+
text-align: center;
56+
background-color: #fff;
57+
max-width: 65vw;
58+
}
59+
</style>
60+
<!--
61+
====================================
62+
HTML
63+
====================================
64+
-->
65+
<paper-material>
66+
67+
<template is="dom-if" if="{{!user}}">
68+
<img src="/images/gde-logo.svg">
69+
<h1>Welcome. Bienvenido. ようこそ.</h1>
70+
<p>Sign in to start logging your Google Expert activities.</p>
71+
<experts-signin
72+
user="{{user}}"></experts-signin>
73+
</template>
74+
<template is="dom-if" if="{{user.notGde}}">
75+
<h2>The email you've used isn't associated to a GDE program account</h2>
76+
<p>You must sign in with the email address you use in the GDE program.</p>
77+
<p>If you've uesed the wrong address, please sign out and then sign in with the right account.</p>
78+
<experts-signin
79+
user="{{user}}"></experts-signin>
80+
</template>
81+
</paper-material>
82+
</template>
83+
<!--
84+
====================================
85+
JS
86+
====================================
87+
-->
88+
<script>
89+
Polymer({
90+
is: 'experts-not-logged-in',
91+
behaviors: [
92+
Polymer.PaperDialogBehavior
93+
],
94+
properties: {
95+
/**
96+
* The user object received from experts-signin
97+
*/
98+
user : {
99+
type : Object,
100+
value: null,
101+
observer: "_userChanged",
102+
notify: true,
103+
},
104+
105+
},
106+
observers: [
107+
],
108+
_userChanged: function() {
109+
if (this.user && this.user.ok) {
110+
this.close();
111+
} else {
112+
this.open();
113+
}
114+
}
115+
});
116+
</script>
117+
</dom-module>

src/experts-signin.html

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -128,28 +128,6 @@
128128
console.debug("[experts-signin] _isAuthorizedChanged", this._isAuthorized);
129129
},
130130

131-
/**
132-
* Basic user information and access rights for the user
133-
*/
134-
_userInfoChanged: function () {
135-
if (!this._googleUser || !this._googleUser.email) {
136-
this._setUser(undefined);
137-
return;
138-
}
139-
140-
var user = {
141-
id: this._googleUser.id,
142-
name: this._googleUser.name,
143-
image: this._googleUser.image,
144-
email: this._googleUser.email,
145-
token: this._googleUser.token,
146-
isGoogler: (this._googleUser.email.split('@')[1] === 'google.com')
147-
};
148-
149-
150-
console.debug("[experts-sign-in] _userInfoChanged", user);
151-
this._setUser(user);
152-
},
153131

154132
/**
155133
* Check if user data is initialized correctly
@@ -162,6 +140,7 @@
162140
console.debug("[experts-profile] _handleAccountInfo - apiUser",this._apiUser);
163141
evt.stopPropagation();
164142
var user = this._googleUser;
143+
user.isGoogler = (this._googleUser.email.split('@')[1] === 'google.com')
165144
if (this._apiUser && this._apiUser.email) {
166145
if (this._apiUser.expert_type) {
167146
user.category = this._apiUser.expert_type;
@@ -175,13 +154,20 @@
175154
user.image = this._apiUser.pic_url;
176155
}
177156
user.product_group = this._apiUser.product_group;
157+
user.ok = true;
178158
}
179159
this._setUser(user);
180160
console.debug("[experts-profile] _handleAccountInfo", this.user);
181161
this.fire('iron-signal', {name: 'user', data: this.user} )
182162
},
183163
_handleAccountError: function(evt, error) {
184-
164+
console.debug("[experts-profile] _handleAccountError", this.evt);
165+
var user = this._googleUser;
166+
user.isGoogler = (this._googleUser.email.split('@')[1] === 'google.com')
167+
user.ok = false;
168+
user.notGde = true;
169+
this._setUser(user);
170+
this.fire('iron-signal', {name: 'user', data: this.user} )
185171
},
186172
});
187173
})();

0 commit comments

Comments
 (0)