public bool RegisterUser() { AccountsJSON accountsJSON = JsonConvert.DeserializeObject <AccountsJSON>(File.ReadAllText(Program.Accounts)); foreach (AccountJSON account in accountsJSON.accounts) //Check if the username exists already { if (account.username == _username) { return(false); } } AccountJSON newAccount = new AccountJSON { username = _username, password = _password }; accountsJSON.accounts.Add(newAccount); string _json = JsonConvert.SerializeObject(accountsJSON); File.WriteAllText(Program.Accounts, _json); return(true); }
public bool LoginUser() { AccountsJSON accountsJSON = JsonConvert.DeserializeObject <AccountsJSON>(File.ReadAllText(Program.Accounts)); foreach (AccountJSON account in accountsJSON.accounts) { if (account.username == _username && account.password == _password) //if the username and password are both correct, log in { return(true); } } return(false); }