示例#1
0
        private static void addApp()
        {
            Console.Write("Name : ");
            string   name           = Console.ReadLine();
            DateTime ExperitionDate = DateTime.Now + TimeSpan.FromDays(15);

            BDDConnection.AddApp(name, ExperitionDate);
        }
示例#2
0
        private static void addAccount()
        {
            Console.Write("Username : "******"Password : "******"Email : ");
            string email = Console.ReadLine();

            BDDConnection.AddAccount(username, password, email);
        }
示例#3
0
        public string Connect(string username, string password)
        {
            if (string.IsNullOrWhiteSpace(password) || string.IsNullOrWhiteSpace(username))
            {
                return("");
            }
            if (BDDConnection.UserPasswordExist(username, password))
            {
                string token  = TokenGen.GetInstance.GenerateToken(15);
                int    IDUser = BDDConnection.getUserID(username);
                BDDConnection.UpdateUserToken(IDUser, token);

                User user = BDDConnection.getUserInfo(username);

                Console.WriteLine(token);

                return(token);
            }
            return("");
        }
示例#4
0
        static void Main(string[] args)
        {
            using (ServiceHost host = new ServiceHost(typeof(Server)))
            {
                BDDConnection.OpenConnection("Server=192.168.56.101;DataBase=ProjetDev;User id=sa;Password=root;");
                host.Open();
                Console.WriteLine("Server is open");
                Console.WriteLine("Press enter to close the Server");
                string input;
                while ((input = Console.ReadLine()) != "exit")
                {
                    switch (input.Trim().ToLower())
                    {
                    case "addapp":
                        addApp();
                        break;

                    case "addaccount":
                        addAccount();
                        break;

                    case "resettokensuser":
                        resetTokensUser();
                        break;

                    case "resettokenapp":
                        resetTokenApp();
                        break;

                    default:
                        Console.WriteLine("Need help ? :\n---- \nAddApp\n----\nAddAccount\n----\nResetTokensuser\n----\nResetTokenapp");
                        break;
                    }
                }
            }
        }
示例#5
0
 private static void resetTokenApp()
 {
     Console.Write("Name of the app : ");
     BDDConnection.ResetTokenApp(Console.ReadLine());
 }
示例#6
0
 private static void resetTokensUser()
 {
     BDDConnection.ResetTokenUser();
 }
示例#7
0
 public bool isAuthenticated(string username, string token)
 {
     return(BDDConnection.CheckTokenUser(username, token));
 }