Example #1
0
        //Implementation of the IAuthenticate interface which will be access by server

        public string Register(String name, String password)
        {
            String loginAndReg = name + "\t" + password;

            FileHandling writeObject = new FileHandling();

            writeObject.writeDataToTextFile(loginAndReg, pathForRegistrationText);

            return("Successfully Registered");
        }
Example #2
0
        /*
         *
         * Login function validates all the component
         * Return a postive token value if Login() successful
         * Return a negative if unsuccessful
         *
         */
        public int Login(String name, String password)
        {
            Random       tokengen     = new Random();
            String       details      = name + "\t" + password;
            FileHandling fileHandling = new FileHandling();

            if (File.ReadAllLines(pathForRegistrationText).Contains(details))
            {
                int token = tokengen.Next(9999);
                fileHandling.writeDataToTextFile(token.ToString(), pathForTokenText);
                //return random positive token if match is found
                return(token);
            }
            else
            {
                //return negative integer as unsuccessfull
                return(-1);
            }
        }