Exemplo n.º 1
0
 public ListOption(string username) // constructor
 {
     listDirectory = "./account_list/" + username + "/lists";
     activeUser    = username;
     file_handler  = new MyFileHandler(username);
     lists         = file_handler.GetAvailableList(listDirectory);
 }
Exemplo n.º 2
0
        public void savePassword(string username, string password)
        {
            var    file_handler = new MyFileHandler(username);
            string path         = "./account_list/" + username + "/key.txt";

            file_handler.WriteToFile(path, password);
        }
Exemplo n.º 3
0
        public bool checkUser(string _password, string _username)
        {
            MyFileHandler file_handler  = new MyFileHandler(_username);
            string        username_path = "./account_list/" + _username;

            if (file_handler.CheckDirectory(username_path))
            {
                string   password_path    = "./account_list/" + _username + "/key.txt";
                string[] fetched_password = File.ReadAllLines(password_path);

                if (_password == fetched_password[0])
                {
                    Console.Clear();

                    //Console.WriteLine("Log in Successfully! ");
                    //Console.ReadLine();
                    //Console.Clear();

                    file_handler.WriteToFile("./account_list./active_user.txt", _username);
                    return(false);
                }
                else
                {
                    error_message("password");
                    return(true);
                }
            }
            else
            {
                error_message("username");
                return(true);
            }
        }
Exemplo n.º 4
0
        public void saveRecovery(string the_question, string username, string recovery_answer)
        {
            var    file_handler  = new MyFileHandler(username);
            string question_path = "./account_list/" + username + "/recovery_question.txt";

            file_handler.WriteToFile(question_path, the_question);

            string answer_path = "./account_list/" + username + "/recovery_answer.txt";

            file_handler.WriteToFile(answer_path, recovery_answer);
        }
Exemplo n.º 5
0
        public string[] ShowList(string username) // for current user show list, or get list
        {
            var    file          = new MyFileHandler(username);
            string listDirectory = $@"./account_list/{username}/lists";

            string[] lists = file.GetAvailableList(listDirectory);

            if (lists.Length != 0) //check if any list exists
            {
                while (true)
                {
                    int listNumber = ValidateChoice.GetNumber(lists.Length, "Lists created by " + username, lists);

                    if (listNumber == 0) //exit
                    {
                        break;
                    }

                    try
                    {
                        string[] toDoList = File.ReadAllLines($@"{listDirectory}/{lists[listNumber-1]}.txt");
                        if (toDoList.Length == 0)
                        {
                            MenuPrinter.PrintMenu(lists[listNumber - 1] + " List", null, new string[] { "List is empty..." });
                            break;
                        }
                        else
                        {
                            MenuPrinter.PrintMenu(lists[listNumber - 1] + " List", toDoList, null);
                            return(toDoList);
                        }
                    }
                    catch
                    {
                        Console.WriteLine("> The list you gave us does not exist!");
                        Console.ReadKey();
                        Console.Clear();
                        continue;
                    }
                }
            }
            else
            {
                Console.WriteLine("> No List Exists...");
            }
            return(null);
        }
Exemplo n.º 6
0
        public bool CheckRecoveryInfo(string username)
        {
            var    file_handler  = new MyFileHandler(username);
            string username_path = "./account_list/" + username;

            if (file_handler.CheckDirectory(username_path))
            {
                string recovery_question_path    = "./account_list/" + username + "/recovery_question.txt";
                string fetched_recovery_question = file_handler.ReadFile(recovery_question_path);

                RecoveryMode(username, fetched_recovery_question);

                return(false);
            }
            else
            {
                Console.WriteLine("Username is unrecognize...\nPlease try again...");
                Console.ReadLine();
                return(true);
            }
        }