Ejemplo n.º 1
0
        private void LogIn(object?_)
        {
            var logInResult = LogInService.LogIn(MailAddress, Password);

            Password = "";

            if (logInResult)
            {
                onLogInSucceededAsSubject.OnNext(Unit.Default);
            }
            else
            {
                onLogInFailedAsSubject.OnNext(Unit.Default);
            }
        }
Ejemplo n.º 2
0
        private async Task LoggingInAsync(User user)
        {
            AccessToken = await LogInService.LogIn(user);

            if (AccessToken == "")
            {
                LoginSuccess = false;
                Password     = "";
                return;
            }

            var userService = new UserService();

            LoggedInUser = await userService.GetUserByName(user.Username);

            LoginSuccess = true;
            NavigationService.Navigate(typeof(LoggedInPage), LoggedInUser);
        }
Ejemplo n.º 3
0
        public void TestInterface_Implementation()
        {
            // Assamble
            // Login types
            LogInToken     logInToken     = new LogInToken("token");
            LogInBasicAuth logInBasicAuth = new LogInBasicAuth("user", "password");

            // Login service that can go for either ways
            LogInService serviceToken     = new LogInService(logInToken);
            LogInService serviceBasicAuth = new LogInService(logInBasicAuth);

            // Act
            serviceToken.LogIn();
            serviceBasicAuth.LogIn();

            // Assert
            Assert.AreEqual(serviceToken.IsLogged(), serviceBasicAuth.IsLogged());
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            while (true)
            {
                int chosenMenu;
                var registrationService = new RegistrationService();
                var loginService        = new LogInService();
                var messanger           = new ConsoleMessage();
                Clear();
                messanger.Send("1.Войти");
                messanger.Send("2.Регистрация");
                chosenMenu = ToInt32(ReadLine());

                switch (chosenMenu)
                {
                case 1:
                    messanger.Send("Введите email: ");
                    var email = ReadLine();
                    messanger.Send("Введите пароль: ");
                    var password = ReadLine();

                    if (loginService.LogIn(email, password))
                    {
                        messanger.Send("Вы успешно авторизовались");
                    }

                    else
                    {
                        messanger.Send("Вы ввели неверные данныe!");
                    }

                    ReadLine();
                    break;

                case 2:
                    Clear();
                    registrationService.Register(messanger);
                    break;
                }
            }
        }
        public async Task Run()
        {
            while (true)
            {
                Console.WriteLine("Menu: [L]ogIn L[i]st [R]un [P]in test [Q]uit");
                var key = Console.ReadKey(true);
                switch (key.KeyChar)
                {
                case 'l':
                case 'L':
                    Console.Write("User: "******"Password: "******"{worker.Name}, ({worker.WorkerId})");
                            foreach (var jobDescription in worker.JobDescriptions)
                            {
                                Console.WriteLine($"   {jobDescription.Name}");
                            }
                            Console.WriteLine();
                        }
                    }
                    catch (Exception e) when(e.Message == "Unauthorized")
                    {
                        Console.WriteLine("Unauthorized");
                    }
                    break;

                case 'r':
                case 'R':
                    Console.Write("Worker id: ");
                    var workerId = Console.ReadLine();
                    Console.Write("Job name: ");
                    var jobName = Console.ReadLine();
                    Console.Write("Job payload: ");
                    var jobPayload = Console.ReadLine();
                    try
                    {
                        jobPayload = jobPayload == "" ? "{}" : jobPayload;
                        await _controlService.RunJob(Settings.RunJobUrl(workerId), jobName, jobPayload);
                    }
                    catch (Exception e) when(e.Message == "Unauthorized")
                    {
                        Console.WriteLine("Unauthorized");
                    }
                    Console.WriteLine();
                    break;

                case 'p':
                case 'P':
                    Console.WriteLine("Testing pins: 23, 24, 5, 6, 13");
                    Console.WriteLine(" OOOOOOOXXOOOOOOOOOOO");
                    Console.WriteLine("|OOOOOOOOOOOOOOXXXOOO");
                    _gpioService.Run();
                    break;

                case 'q':
                case 'Q':
                    return;

                default:
                    break;
                }
            }
        }