Switched to Firebase.prototype.onAuth() in auth/auth.js to fix the login button. Right now, the login button sends some XMLHttpRequest() with Firebase.prototype.authWithOAuthRedirect(), refreshes the page, and then finished the HTTP request after the refreshed page has been loaded. This means that the user isn't actually logged in until after the refreshed page has been loaded, so the login button stays after the user has been logged in because we haven't sensed the user login on the page load. There is no way for us to sense the user log in other than using Firebase to tell us, which is why Firebase.prototype.onAuth() is really the best solution to hide the login button and show the logout button when the user clicks the login button.
Switched to Contest_Judging_System.logInAndGetUserData() in contest.js and entry.js. This gets rid of a significant amount of unnecessary code and makes our code have less indentation.
In entry.js, I switched judge checking from permLevel >= 4 to entryData.hasOwnProperty("scores"). This way, the perm level for judges is only written in Backend/contest_judging_sys.js, making it very easy to switch the perm level for a judge from a 4 to (for example), a 3 or 5.
Got rid of contest name validation in admin/scripts/new_contest.js (We're getting the contest name through the ID, so I don't know why we have this.)
Please test this on a new branch so you can see that I haven't broke anything. Although there are almost 300 additions and over 300 deletions in this pull request, most of these changes are indentation changes. I have changed very little. I have tested /, /contest.html, /entry.html, /admin/, and /admin/new_contest.html and nothing broke for me.
Here's a breakdown on my changes:
Firebase.prototype.onAuth()
inauth/auth.js
to fix the login button. Right now, the login button sends someXMLHttpRequest()
withFirebase.prototype.authWithOAuthRedirect()
, refreshes the page, and then finished the HTTP request after the refreshed page has been loaded. This means that the user isn't actually logged in until after the refreshed page has been loaded, so the login button stays after the user has been logged in because we haven't sensed the user login on the page load. There is no way for us to sense the user log in other than using Firebase to tell us, which is whyFirebase.prototype.onAuth()
is really the best solution to hide the login button and show the logout button when the user clicks the login button.Contest_Judging_System.logInAndGetUserData()
incontest.js
andentry.js
. This gets rid of a significant amount of unnecessary code and makes our code have less indentation.entry.js
, I switched judge checking frompermLevel >= 4
toentryData.hasOwnProperty("scores")
. This way, the perm level for judges is only written inBackend/contest_judging_sys.js
, making it very easy to switch the perm level for a judge from a 4 to (for example), a 3 or 5.admin/scripts/new_contest.js
(We're getting the contest name through the ID, so I don't know why we have this.)Please test this on a new branch so you can see that I haven't broke anything. Although there are almost 300 additions and over 300 deletions in this pull request, most of these changes are indentation changes. I have changed very little. I have tested
/
,/contest.html
,/entry.html
,/admin/
, and/admin/new_contest.html
and nothing broke for me.