/// <summary> /// Function for checking the existence of the username in the database /// </summary> /// <param name="userName"></param> /// <returns></returns> public async Task CheckUsernameExist(string userName) { chkUsernameResult = false; LoginDbHandler.GetUsers(userDatas => { foreach (var userData in userDatas) { Debug.Log($"{userData.Key}"); if (userData.Value.userName == userName) { chkUsernameResult = true; break; } } }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Username check elapsed milliseconds: {0}" + sec); }
/// <summary> /// Get the student data during login. /// </summary> /// <param name="localID"></param> /// <returns></returns> public async Task <bool> ChkStudent(string localID) { bool chk = false; LoginDbHandler.GetStudent(localID, student => { chk = true; userData = new UserData(); userData.coin = student.coin; userData.email = student.email; userData.experience = student.experience; userData.hp = student.hp; userData.level = student.level; userData.localId = student.localId; userData.maxExperience = student.maxExperience; userData.userName = student.userName; userData.verified = student.verified; }); Stopwatch sw = Stopwatch.StartNew(); var delay = Task.Delay(1000).ContinueWith(_ => { sw.Stop(); return(sw.ElapsedMilliseconds); }); await delay; int sec = (int)delay.Result; Debug.Log("Time elapsed milliseconds: {0}" + sec + ", Chk is " + chk); return(chk); }
/// <summary> /// ddisplay battle results /// </summary> private void toggleResultScreen() { twitterShareController.setResults(normal.levelNo, score); questionUI.SetActive(false); resultUIScript.gameObject.SetActive(true); userData.setCoin(userData.getCoin() + monsterScript.Coin); //level up if (userData.getMaxExperience() <= userData.getExperience() + monsterScript.Experience) { userData.setLevel(userData.getLevel() + 1); userData.setExperience(userData.getMaxExperience() - userData.getExperience() + monsterScript.Experience); } else { userData.setExperience(userData.getExperience() + monsterScript.Experience); } LoginDbHandler.UpdateToDatabase(userData); if (PlayerHealth <= 0) { resultUIScript.setResults(score, 0, 0); } else { resultUIScript.setResults(score, monsterScript.Coin, monsterScript.Experience); } mainMenuControllerScript.loadMainMenu(); if (isThisNormalLevel) { RestClient.Put($"https://engeenur-17baa.firebaseio.com/score/" + userData.getName() + "/levelScore/" + normal.levelNo + ".json", score.ToString()); } else { RestClient.Put($"https://engeenur-17baa.firebaseio.com/specialScore/" + special.courseName + "/" + userData.getName() + ".json", score.ToString()); } }
public ActionResult performLogin(User u) { String email = u.email; String pass = u.password; //check fields if (email.Equals("") || pass.Equals("")) { return(RedirectToAction("LoginSignup")); } u = LoginDbHandler.login(email, pass); if (u != null) { switch (u.type) { case "Student": return(RedirectToAction("StudentDashboard")); break; case "Teacher": return(RedirectToAction("TeacherDashboard")); break; } } //else show error // Content("<script language='javascript' type='text/javascript'>alert('Invalid email or password');</script>"); return(RedirectToAction("LoginSignup")); }
public MainController(ServerManager serverManager, ILogger <MainController> logger, LoginDbHandler authHandler) { //This constructor is called for every request. Therefore, keep it slim _serverManager = serverManager; //Save injected logger _logger = logger; _authHandler = authHandler; _logger.LogTrace($"{nameof(MainController)} initialized"); }
public string validateEmail(string email) { bool x = LoginDbHandler.checkEmail(email); if (x) { return("false"); } else { return("true"); } }