示例#1
0
        private async Task SignIn()
        {
            var username = UsernameTextBox.Text;
            var password = PasswordTextBox.Text;

            var user = await Services.UserManager.FindByNameAsync(username).ConfigureAwait(true);

            if (user is null)
            {
                UiUtils.ErrorMessageBox("Your username and/or password is incorrect", "Invalid Credentials");
                return;
            }

            var signInResult = await Services.SignInManager.CheckPasswordSignInAsync(user, password, false).ConfigureAwait(true);

            if (!signInResult.Succeeded)
            {
                UiUtils.ErrorMessageBox("Your username and/or password is incorrect", "Invalid Credentials");
                return;
            }

            Services.UserContext.SignIn(user);

            UsernameTextBox.ResetText();
            PasswordTextBox.ResetText();

            Hide();

            var dashboardForm = new DashboardForm(Services);

            dashboardForm.ShowDialog();

            Show();
        }