}//check that the user name and the password is in the pattern that needed public void RegisterClick()//make the registraion to the data base and create a profile { db = new DbPlayer(); if (check(firstName.text, Errors) && check(lastName.text, Errors) && check(Email.text, Errors) && check(confirm.text, Errors) && patternCheck(password.text, Errors) && patternCheck(userName.text, Errors)) { if (!db.ExistUser(userName.text)) { if (password.text.Equals(confirm.text)) { PlayerData info = new PlayerData(); info.SetPlayer(firstName.text, lastName.text, Email.text, userName.text, password.text, profileImage.value); db.InsertPlayer(info); SceneManager.LoadScene("LoginPage"); } else { Errors.text = "You Must Confirm The Password"; } } else { Errors.text = "User Name Is Allready Taken"; } } }
public void LoginClick()//function that check the user name and the password after a user tries to Login { db = new DbPlayer(); if (db.ExistUser(userName.text)) { if (!db.isUserConnected(userName.text)) { PlayerData info = db.GetPlayerByUserName(userName.text); if (info.Password == Password.text) { PlayerPrefs.SetString("userName", info.UserName); PlayerPrefs.SetInt("ImageOffset", info.PlayerImage); PlayerPrefs.Save(); db.addUserConnection(info.UserName); SceneManager.LoadScene("lobbytest"); } else { Errors.text = "Worng Password"; } } else { Errors.text = "This User Allready Conntected"; } } else { Errors.text = "User Dont Exist In The Data Base"; } }
}//check that the user name and the password is in the pattern that needed public void RegisterClick()//make the registraion to the data base and create a profile { string patternA = @"[A-Za-z]$";//check if all are alfabet. db = new DbPlayer(); Match matchFname = Regex.Match(firstName.text, patternA); Match matchLname = Regex.Match(firstName.text, patternA); Match matchEmail = Regex.Match(Email.text, @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" + @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-z][-0-9a-z]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9]{0,22}[a-z0-9]))$"); if (check(firstName.text, Errors) && check(lastName.text, Errors) && check(Email.text, Errors) && check(confirm.text, Errors) && patternCheck(password.text, Errors) && patternCheck(userName.text, Errors)) { if (matchEmail.Success && matchFname.Success && matchLname.Success) { if (!db.ExistUser(userName.text)) { if (password.text.Equals(confirm.text)) { PlayerData info = new PlayerData(); info.SetPlayer(firstName.text, lastName.text, Email.text, userName.text, password.text, profileImage.value); db.InsertPlayer(info); SceneManager.LoadScene("LoginPage"); } else { Errors.text = "You Must Confirm The Password"; } } else { Errors.text = "User Name Is Allready Taken"; } } else { Errors.text = "Wrong input Email/First Name/Last Name"; } } }