public User LoginSignup(IProvideData DataProvider, string startingOption = "SignUp") { startingOption = SelectionMenu.Horizontal(new List <string> { "Login", "SignUp", "Exit" }, Headers.headerw).NameOfChoice; Console.Clear(); if (startingOption == "Exit") { Environment.Exit(0); } string GivenUsername = ReadUsername(); string GivenPassword = ReadPassword(); if (startingOption == "SignUp") { User u1 = new User() { Username = GivenUsername, Password = GivenPassword, UsersPrivilege = DataProvider.IsStorageEmpty() ? Privilege.admin : Privilege.user }; Debug.Write("New User was created successfully: " + DataProvider.CreateUser(u1)); return(u1); } else if (startingOption == "Login") { return(ValidLogin(GivenUsername, GivenPassword)); } return(null); }
public void CreateUser() { LoginOrSignup CreateNewUser = new LoginOrSignup(DataProvider); User u2 = new User() { Username = CreateNewUser.ReadUsername(), Password = CreateNewUser.ReadPassword(), UsersPrivilege = Privilege.user }; DataProvider.CreateUser(u2); Console.WriteLine($"User \"{u2.Username}\" has been created!"); }