Adjustments to auth.js

master
Skylar Ittner 8 years ago
parent 17279e7a5b
commit c580b8e6e8

@ -51,12 +51,13 @@ function logout() {
}); });
} }
var teamchoosercheckretried = false;
function checkUserHasTeamOpenChooserIfNot(username) { function checkUserHasTeamOpenChooserIfNot(username) {
$.getJSON(mkApiUrl('getstats'), { $.getJSON(mkApiUrl('getstats'), {
user: username user: username
}, function (data) { }, function (data) {
if (data.status === 'OK') { if (data.status === 'OK') {
if (data.stats.teamid !== null && data.stats.teamid > 0) { if (data.stats.teamid && data.stats.teamid > 0) {
// We're all good. // We're all good.
userteamid = data.stats.teamid; userteamid = data.stats.teamid;
openscreen("home"); openscreen("home");
@ -65,7 +66,13 @@ function checkUserHasTeamOpenChooserIfNot(username) {
openscreen('chooseteam'); openscreen('chooseteam');
} }
} else { } else {
serverProblemsDialog("Got a bad answer from the server. Restart the app and try again."); // Might fix a strange bug that might not exist.
if (!teamchoosercheckretried) {
teamchoosercheckretried = true;
checkUserHasTeamOpenChooserIfNot(username);
} else {
serverProblemsDialog("Got a bad answer from the server. Restart the app and try again.");
}
} }
}).fail(function () { }).fail(function () {
serverProblemsDialog("Cannot get player data from server."); serverProblemsDialog("Cannot get player data from server.");