Beispiel #1
0
        public async Task <AuthInfoDto> Authorize(AuthorizeAccountCommand command)
        {
            var account = await queryFactory.ResolveQuery <AccountByLoginAndPasswordQuery>()
                          .Execute(command.Login, command.Password);

            return(AccountApiService.CreateAuthInfo(account));
        }
Beispiel #2
0
        private async void BtnLogin_Click(object sender, RoutedEventArgs e)
        {
            if (tbEmail.Text != "" || tbPassword.Password != "")
            {
                lbWarning.Content = "";

                AccountApiService service = new AccountApiService();

                // посилаємо модель на сервер
                var responseObj = await service.LoginAsync(new AccountModel
                {
                    Email    = tbEmail.Text,
                    Password = tbPassword.Password
                });

                if (responseObj == null)
                {
                    lbWarning.Foreground = Brushes.Red;
                    lbWarning.Content    = "Неправильно введені дані";
                }
                else
                {
                    MainWindow window = new MainWindow(responseObj);
                    window.Show();
                    this.Close();
                }
            }
        }
Beispiel #3
0
 public AccountController(
     ICommandFactory commandFactory,
     IQueryFactory queryFactory,
     IMapper mapper,
     AccountApiService accountApiService)
 {
     this.commandFactory    = commandFactory;
     this.queryFactory      = queryFactory;
     this.mapper            = mapper;
     this.accountApiService = accountApiService;
 }
        private async void BtnLogout_Click(object sender, RoutedEventArgs e)
        {
            AccountApiService service = new AccountApiService();
            bool Logout = await service.LogoutAsync(userEmail);

            if (Logout)
            {
                LoginWindow window = new LoginWindow();
                window.Show();
                this.Close();
            }
        }
        private async void BtnSend_Click(object sender, RoutedEventArgs e)
        {
            tbWarningFirstName.Text       = "";
            tbWarningLastName.Text        = "";
            tbWarningPassword.Text        = "";
            tbWarningConfirmPassword.Text = "";
            tbWarningEmail.Text           = "";
            tbWarningPhone.Text           = "";

            if (tbPassword.Password != tbConfirmPassword.Password)
            {
                tbWarningPassword.Text        = "Пароль не співпадає";
                tbWarningConfirmPassword.Text = "Пароль не співпадає";
                return;
            }
            if (tbFirstName.Text == tbLastName.Text && tbFirstName.Text != "")
            {
                tbWarningFirstName.Text = "Поле FirstName та LastName не можуть співпадати";
                tbWarningLastName.Text  = "Поле FirstName та LastName не можуть співпадати";
                return;
            }

            // відправляємо модель на сервер
            AccountApiService service = new AccountApiService();

            var errorList = await service.RegistrationAsync(new UserModel
            {
                FirstName = tbFirstName.Text,
                LastName  = tbLastName.Text,
                Password  = tbPassword.Password,
                Email     = tbEmail.Text,
                Phone     = tbPhone.Text
            });

            // витягуємо помилки, якщо поля невалідні
            if (errorList != null)
            {
                foreach (var item in errorList)
                {
                    if ("firstName" == item.Key)
                    {
                        tbWarningFirstName.Text = item.Value;
                    }

                    if ("lastName" == item.Key)
                    {
                        tbWarningLastName.Text = item.Value;
                    }

                    if ("password" == item.Key)
                    {
                        tbWarningPassword.Text = item.Value;
                    }

                    if ("email" == item.Key)
                    {
                        tbWarningEmail.Text = item.Value;
                    }

                    if ("phone" == item.Key)
                    {
                        tbWarningPhone.Text = item.Value;
                    }
                }
            }
            // в іншому випадку реєстрація успішна
            else
            {
                tbWarningPhone.Foreground = Brushes.Blue;
                tbWarningPhone.Text       = "Реєстрація успішна";

                btnSend.IsEnabled = false;
            }
        }