Skip to content

Commit 81ab1fd

Browse files
committed
fix authentication
1 parent 6ce5f3c commit 81ab1fd

File tree

4 files changed

+97
-14
lines changed

4 files changed

+97
-14
lines changed

community/index.html

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,13 +294,11 @@ <h1>Community</h1>
294294
console.log(error);
295295
});
296296
}
297-
298297
function signIn() {
299298
uiConfig.signInSuccessUrl = "/community/";
300299
uiAuth.start('#firebaseui-auth-container', uiConfig);
301300
}
302301
window.signIn = signIn;
303-
304302
function signOut() {
305303
firebase.auth().signOut();
306304
}

index.html

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,12 +301,47 @@ <h1 style="padding-bottom:2rem;">Agenda</1>
301301
<script defer src="https://www.gstatic.com/firebasejs/7.12.0/firebase-auth.js"></script>
302302
<script defer src="https://www.gstatic.com/firebasejs/7.12.0/firebase-database.js"></script>
303303

304-
<script type="module">
304+
<!-- <script type="module">
305305
const circleName = "MiserableSkills"; function initApp() { firebase.auth().onAuthStateChanged((user) => { if (user) { const {displayName, email, emailVerified, photoURL, uid, phoneNumber, providerData} = user; user.getIdToken().then(function(accessToken)
306306
{ document.querySelector("#userAvatar img").src = photoURL; document.querySelector("#userAvatar").style.display = "inline-block"; document.getElementById("loginStatus").innerHTML = `${displayName} (<a style="color:white" href="#" onclick="signOut()">Sign Out</a>)`;
307307
}); // prompt("Copy/paste this information:","Go to: https://www.crowdcast.io/e/brainweb\nUse this: BrainWebKickOff!") } else { document.querySelector("#userAvatar").style.display = "none"; document.querySelector("#userAvatar img").src = ""; document.getElementById("loginStatus").innerHTML
308308
= `<a style="color:white" href="#" onclick="signIn()">Sign In</a>`; } }, function(error) { console.log(error); }); } function signIn() { uiAuth.start('#firebaseui-auth-container', uiConfig); } window.signIn = signIn; function signOut() { firebase.auth().signOut();
309309
} window.signOut = signOut; function startFirebase() { uiAuth = new firebaseui.auth.AuthUI(firebase.auth()); window.addEventListener('load', function() { initApp(); }); } window.startFirebase = startFirebase;
310+
</script> -->
311+
<script>
312+
function initApp() {
313+
firebase.auth().onAuthStateChanged((user) => {
314+
if (user) {
315+
const {displayName, email, emailVerified, photoURL, uid, phoneNumber, providerData} = user;
316+
user.getIdToken().then(function(accessToken) {
317+
document.querySelector("#userAvatar img").src = photoURL;
318+
document.querySelector("#userAvatar").style.display = "inline-block";
319+
document.getElementById("loginStatus").innerHTML = `${displayName} (<a style="color:white" href="#" onclick="signOut()">Sign Out</a>)`;
320+
});
321+
} else {
322+
document.querySelector("#userAvatar").style.display = "none";
323+
document.querySelector("#userAvatar img").src = "";
324+
document.getElementById("loginStatus").innerHTML = `<a style="color:white" href="#" onclick="signIn()">Sign In</a>`;
325+
}
326+
}, function(error) {
327+
console.log(error);
328+
});
329+
}
330+
function signIn() {
331+
uiConfig.signInSuccessUrl = "/";
332+
uiAuth.start('#firebaseui-auth-container', uiConfig);
333+
}
334+
window.signIn = signIn;
335+
function signOut() {
336+
firebase.auth().signOut();
337+
}
338+
window.signOut = signOut;
339+
function startFirebase() {
340+
uiAuth = new firebaseui.auth.AuthUI(firebase.auth());
341+
window.addEventListener('load', function() {
342+
initApp();
343+
});
344+
}
310345
</script>
311346

312347
<script>

ohbm2020/index.html

Lines changed: 60 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,18 @@
2525
<link href="https://cdn.jsdelivr.net/npm/quasar@1.9.10/dist/quasar.min.css" rel="stylesheet" type="text/css">
2626
<link href="https://cdn.jsdelivr.net/npm/animate.css@^3.5.2/animate.min.css" rel="stylesheet">
2727

28-
<link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" />
28+
<!-- <link rel="shortcut icon" type="image/x-icon" href="./favicon.ico" /> -->
2929
<link href="https://fonts.googleapis.com/css?family=Raleway:100,300,400,500,900" rel="stylesheet">
3030
<link href="https://fonts.googleapis.com/css?family=Oswald:700" rel="stylesheet">
3131

3232
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css">
3333
<link rel="stylesheet" type="text/css" href="/css/main.css">
34+
35+
<link
36+
rel="icon"
37+
sizes="any"
38+
href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 10'%3E%3Ccircle cx='5' cy='5' r='5' fill='grey'/%3E%3C/svg%3E"
39+
>
3440
</head>
3541

3642
<style>
@@ -92,7 +98,7 @@
9298
display: block;
9399
width: 100%;
94100
color:white;
95-
font-size: 0.8rem;
101+
font-size: 0.9rem;
96102
padding: 10px 36px;
97103
}
98104
#info > a {
@@ -112,7 +118,7 @@
112118
}
113119
</style>
114120

115-
<body">
121+
<body>
116122
<!-- navigation bar -->
117123
<nav class="navbar navbar-expand-lg fixed-top ">
118124

@@ -190,9 +196,10 @@
190196

191197
<div style="position:relative;display:flex;flex-direction:column;height:calc( 100% - 65px);margin-top:65px">
192198
<div id="info" style="flex:0 0 120px">
193-
Welcome to the <a href="/" target="_blank">BrainWeb</a> visualiser for the OHBM 2020 Posters. Each square represents a poster.
194-
Green squares show in real-time active posters and the number indicates how many participants
195-
are connected. Many thanks to the
199+
Welcome to the <a href="/" target="_blank">BrainWeb</a> visualiser for the
200+
<a href="https://www.humanbrainmapping.org/i4a/pages/index.cfm?pageid=3958">OHBM 2020</a> posters. Each
201+
square represents a poster. Green squares show in real-time active posters and the number indicates how
202+
many participants are connected. Many thanks to the
196203
<a href="https://datalad-datasets.github.io/ohbm2020-posters/" target="_blank">DataLad</a> team for setting
197204
up all the online tracking system and poster information!
198205
The <a href="/" target="_blank">BrainWeb</a> aims at providing a permanent space for meeting and hacking, available all year
@@ -210,9 +217,48 @@
210217
</body>
211218

212219
<script src="https://cdnjs.cloudflare.com/ajax/libs/reconnecting-websocket/1.0.0/reconnecting-websocket.min.js"></script>
220+
<link type="text/css" rel="stylesheet" href="https://www.gstatic.com/firebasejs/ui/4.5.0/firebase-ui-auth.css" />
221+
<script defer src="https://www.gstatic.com/firebasejs/ui/4.5.0/firebase-ui-auth.js"></script>
222+
<script defer src="https://www.gstatic.com/firebasejs/7.12.0/firebase-app.js"></script>
223+
<script defer src="https://www.gstatic.com/firebasejs/7.12.0/firebase-auth.js"></script>
224+
<script defer src="https://www.gstatic.com/firebasejs/7.12.0/firebase-database.js"></script>
213225
<script>
214226
let posters;
215227

228+
function initApp() {
229+
firebase.auth().onAuthStateChanged((user) => {
230+
if (user) {
231+
const {displayName, email, emailVerified, photoURL, uid, phoneNumber, providerData} = user;
232+
user.getIdToken().then(function(accessToken) {
233+
document.querySelector("#userAvatar img").src = photoURL;
234+
document.querySelector("#userAvatar").style.display = "inline-block";
235+
document.getElementById("loginStatus").innerHTML = `${displayName} (<a style="color:white" href="#" onclick="signOut()">Sign Out</a>)`;
236+
});
237+
} else {
238+
document.querySelector("#userAvatar").style.display = "none";
239+
document.querySelector("#userAvatar img").src = "";
240+
document.getElementById("loginStatus").innerHTML = `<a style="color:white" href="#" onclick="signIn()">Sign In</a>`;
241+
}
242+
}, function(error) {
243+
console.log(error);
244+
});
245+
}
246+
function signIn() {
247+
uiConfig.signInSuccessUrl = "/ohbm2020/";
248+
uiAuth.start('#firebaseui-auth-container', uiConfig);
249+
}
250+
window.signIn = signIn;
251+
function signOut() {
252+
firebase.auth().signOut();
253+
}
254+
window.signOut = signOut;
255+
function startFirebase() {
256+
uiAuth = new firebaseui.auth.AuthUI(firebase.auth());
257+
window.addEventListener('load', function() {
258+
initApp();
259+
});
260+
}
261+
216262
async function getPosters() {
217263
let res = await fetch("posters.json");
218264
const data = await res.json();
@@ -272,9 +318,14 @@
272318

273319
function websocketDump(dump) {
274320
for(key in dump) {
275-
if({}.hasOwnProperty.call(dump, key)) {
321+
if(key !== "" && {}.hasOwnProperty.call(dump, key)) {
276322
const el = document.getElementById(`${key}`);
277-
el.classList.add("connected");
323+
try {
324+
el.classList.add("connected");
325+
} catch (e) {
326+
console.log(e);
327+
console.log(`key: [${key}]`, dump);
328+
}
278329
el.innerText=dump[key];
279330
el.dataset.connected = dump[key];
280331
}
@@ -347,4 +398,5 @@
347398

348399
main();
349400
</script>
401+
<script defer src="/js/init-firebase.js"></script>
350402
</html>

videoconference/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,24 +195,22 @@
195195
console.log(error);
196196
});
197197
}
198-
199198
function signIn() {
200199
uiConfig.signInSuccessUrl = "/videoconference/";
201200
uiAuth.start('#firebaseui-auth-container', uiConfig);
202201
}
203202
window.signIn = signIn;
204-
205203
function signOut() {
206204
firebase.auth().signOut();
207205
}
208206
window.signOut = signOut;
209-
210207
function startFirebase() {
211208
uiAuth = new firebaseui.auth.AuthUI(firebase.auth());
212209
window.addEventListener('load', function() {
213210
initApp();
214211
});
215212
}
213+
216214
function feedbackAnimationStep(timer, elem) {
217215
const dx = 500 * Math.random() - 250;
218216
const x = parseInt("0" + elem.style.left);

0 commit comments

Comments
 (0)