Added confirmation password loop
removed commented code and unused files
This commit is contained in:
parent
cc71d41cca
commit
7575354797
@ -221,8 +221,9 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||
return "Back to Login";
|
||||
// Create account
|
||||
case 1:
|
||||
// Get all credentials and create newUser
|
||||
UserAccount newUser = new UserAccount(newCredentials.GetUserName(),
|
||||
newCredentials.GetPassword(), newCredentials.GetEmail(),
|
||||
newCredentials.ConfirmPassword(), newCredentials.GetEmail(),
|
||||
newCredentials.GetRole(), DateTime.UtcNow);
|
||||
bool accountValid = accountService.CreateUserRecord(newUser, user.username, dbSource);
|
||||
if (accountValid is true)
|
||||
|
||||
@ -5,7 +5,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||
{
|
||||
{ // Class for getting user credentials
|
||||
public class GetCredentials
|
||||
{
|
||||
public string? GetUserName()
|
||||
@ -20,11 +20,26 @@ namespace TeamHobby.HobbyProjectGenerator.UserManagement
|
||||
string? userPassword = Console.ReadLine();
|
||||
return userPassword;
|
||||
}
|
||||
/*public string ConfirmPassword()
|
||||
public string ConfirmPassword()
|
||||
{
|
||||
Console.WriteLine();
|
||||
string confirmPassword = newUser.NewPassword;
|
||||
}*/
|
||||
while (true)
|
||||
{
|
||||
Console.WriteLine("Please enter a password:");
|
||||
string? userPassword = Console.ReadLine();
|
||||
// Confirm Password
|
||||
Console.WriteLine("Please re-enter the password:");
|
||||
string checkPsswd = Console.ReadLine();
|
||||
// Check if passwords match
|
||||
if (userPassword == checkPsswd)
|
||||
{
|
||||
return userPassword;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Passwords do not match.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
public string GetEmail()
|
||||
{
|
||||
Console.WriteLine("Please enter an email:");
|
||||
|
||||
@ -5,22 +5,7 @@ using TeamHobby.HobbyProjectGenerator.DataAccess;
|
||||
using TeamHobby.HobbyProjectGenerator.UserManagement;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
{
|
||||
public class GetCredentials
|
||||
{
|
||||
public string? GetUserName()
|
||||
{
|
||||
Console.WriteLine("Please enter a username:");
|
||||
string? userName = Console.ReadLine();
|
||||
return userName;
|
||||
}
|
||||
public string? GetPassword()
|
||||
{
|
||||
Console.WriteLine("Please enter " +
|
||||
"a password:");
|
||||
string? userPassword = Console.ReadLine();
|
||||
return userPassword;
|
||||
}
|
||||
{
|
||||
public class Controller
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
@ -156,82 +141,6 @@ namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
//Console.WriteLine("Writing to the database... ");
|
||||
//datasource.WriteData(sqlRemove);
|
||||
//Console.WriteLine("Writing completed. ");
|
||||
|
||||
/* bool MainMenu = true;
|
||||
|
||||
// Set up menu loop
|
||||
while (MainMenu == true)
|
||||
{
|
||||
// Console customization
|
||||
// Change the look of the console
|
||||
Console.Title = "HobbyProjectGenerator";
|
||||
// Change console text color
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
// Change terminal height
|
||||
Console.WindowHeight = 40;
|
||||
|
||||
|
||||
// Create class objects
|
||||
UiPrint menu = new UiPrint();
|
||||
|
||||
|
||||
// Print main menu
|
||||
menu.InitialMenu();
|
||||
|
||||
// Set up try-catch for invalid inputs
|
||||
try
|
||||
{
|
||||
// Get user choice
|
||||
string initialChoice = Console.ReadLine();
|
||||
// Convert to integer
|
||||
int Choice = Convert.ToInt32(initialChoice);
|
||||
|
||||
switch (Choice)
|
||||
{
|
||||
case 0:
|
||||
MainMenu = false;
|
||||
break;
|
||||
// Create a new account
|
||||
case 1:
|
||||
user.newUser();
|
||||
break;
|
||||
// Access Admin features
|
||||
case 2:
|
||||
// Ask for Admin login credentials
|
||||
Console.WriteLine("Please enter a username:");
|
||||
string AdminUser = Console.ReadLine();
|
||||
Console.WriteLine("Please enter the password for" + AdminUser);
|
||||
string AdminPsswrd = Console.ReadLine();
|
||||
|
||||
// Check if the username and password match a record within the administrators
|
||||
|
||||
|
||||
// Show new administrator menu
|
||||
int AdminNum = 0;
|
||||
Console.WriteLine("Welcome" + AdminUser);
|
||||
Console.WriteLine("What would you like to do?");
|
||||
Console.WriteLine("1.View normal user records.");
|
||||
Console.WriteLine("2.View Administrator user records.");
|
||||
Console.WriteLine("3.View log files.");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine("Invalid choice, please enter a valid number.");
|
||||
break;
|
||||
};
|
||||
}
|
||||
// Catch invalid keys such as spamming enter
|
||||
catch
|
||||
{
|
||||
MainMenu = false;
|
||||
};*/
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TeamHobby.HobbyProjectGenerator.Main
|
||||
{
|
||||
public class MainMenu
|
||||
{
|
||||
/*static void Main(string[] args)
|
||||
{
|
||||
/* ExampleDAO z = new ExampleDAO();
|
||||
z.UserData("Tomato");
|
||||
Console.Read();*/
|
||||
/*bool menu = true;
|
||||
|
||||
// Set up menu loop
|
||||
while (menu == true)
|
||||
{
|
||||
// Console customization
|
||||
// Change the look of the console
|
||||
Console.Title = "HobbyProjectGenerator";
|
||||
// Change console text color
|
||||
Console.ForegroundColor = ConsoleColor.Green;
|
||||
// Change terminal height
|
||||
Console.WindowHeight = 40;
|
||||
|
||||
|
||||
// Create intial menu
|
||||
Console.WriteLine("What would you like to do?");
|
||||
int num = 1;
|
||||
Console.WriteLine(num + ".Create a new user account.");
|
||||
num += 1;
|
||||
Console.WriteLine(num + ".Acess Admin Features.");
|
||||
|
||||
// Set up try-catch for invalid inputs
|
||||
try
|
||||
{
|
||||
// Get user choice
|
||||
string initialChoice = Console.ReadLine();
|
||||
// Convert to integer
|
||||
int Choice = Convert.ToInt32(initialChoice);
|
||||
|
||||
switch (Choice)
|
||||
{
|
||||
// Create a new account
|
||||
case 1:
|
||||
// Get username
|
||||
Console.WriteLine("Please enter a username:");
|
||||
string userName = Console.ReadLine();
|
||||
|
||||
// Get Password
|
||||
Console.WriteLine("Please enter a password:");
|
||||
string userPassword = Console.ReadLine();
|
||||
|
||||
// Create bool value for password confirm loop
|
||||
bool conPsswrd = true;
|
||||
// Loop until password is confirmed
|
||||
while (conPsswrd == true)
|
||||
{
|
||||
// Confirm Password
|
||||
Console.WriteLine("Please re-enter the password:");
|
||||
string checkPsswd = Console.ReadLine();
|
||||
// Check if passwords match
|
||||
if (userPassword == checkPsswd)
|
||||
{
|
||||
// Get Security question for password reset
|
||||
Console.WriteLine("Please enter a security question.\n" +
|
||||
"(EX: What is your favorite food?");
|
||||
string SecQuest = Console.ReadLine();
|
||||
// Get Security question answer
|
||||
Console.WriteLine("Please enter the answer for your security question:");
|
||||
String SecAnswer = Console.ReadLine();
|
||||
|
||||
// Call user manager method to create the new user
|
||||
//int userCreateConfirm = new CreateUser(userName,userPassword,SecQuest,SecAnswer);
|
||||
|
||||
// Check if user creation was successful
|
||||
/* if (userCreateConfirm = 1)
|
||||
{
|
||||
|
||||
// Confirm to user that the account has been created
|
||||
Console.WriteLine("Account created succesfully with the username of" + userName);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}*/
|
||||
/* conPsswrd = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("Passwords did not match, please try again.");
|
||||
}
|
||||
}
|
||||
break;
|
||||
// Access Admin features
|
||||
case 2:
|
||||
// Ask for Admin login credentials
|
||||
Console.WriteLine("Please enter a username:");
|
||||
string AdminUser = Console.ReadLine();
|
||||
Console.WriteLine("Please enter the password for" + AdminUser);
|
||||
string AdminPsswrd = Console.ReadLine();
|
||||
|
||||
// Check if the username and password match a record within the administrators
|
||||
|
||||
|
||||
// Show new administrator menu
|
||||
int AdminNum = 0;
|
||||
Console.WriteLine("Welcome" + AdminUser);
|
||||
Console.WriteLine("What would you like to do?");
|
||||
Console.WriteLine("1.View normal user records.");
|
||||
Console.WriteLine("2.View Administrator user records.");
|
||||
Console.WriteLine("3.");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
Console.WriteLine("");
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
menu = false;
|
||||
break;
|
||||
};
|
||||
}
|
||||
// Catch invalid keys such as spamming enter
|
||||
catch
|
||||
{
|
||||
menu = false;
|
||||
};
|
||||
}*/
|
||||
|
||||
//}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user