Exemplo n.º 1
0
        static void Login(string keyIn)
        {
            Draw.Prompt("Authenticating. . .");

            AuthenticationResult newUser;

            try {
                newUser = controller.Authenticate(keyIn);
            }
            catch (Exception ex) {
                Log.Exception(ex);

                if (ex.Message.Contains("403 (Forbidden)") || ex.Message.Contains("Invalid key"))
                {
                    Draw.Prompt("Invalid key");
                }
                else
                {
                    Connect();
                }

                return;
            }

            if (!newUser.AccessGranted)
            {
                Draw.Prompt("Expired membership");

                return;
            }

            inputCleared = true;
            key          = keyIn;
            user         = newUser;

            if (cabinetMode)
            {
                EnterCabinetMenu();
            }
            else
            {
                expiration = DateTime.Now + new TimeSpan(0, 0, config.Timeout);

                Draw.Status(config.Timeout, false);
                Draw.User(user);
                ReaderHardware.Login();
            }
        }