Exemplo n.º 1
0
        private async void login_btn_Click(object sender, RoutedEventArgs e)
        {
            if (userid.Text == "" || password.Password == "")
            {
                Tips_block.Visibility = Visibility.Visible;
            }
            else
            {
                if (_claimsStored != null && _claimsStored.IsAuthenticated == true)
                {
                    SendClaimsEvent?.Invoke(_claimsStored);
                    return;
                }
                IdentityHelper ih = IdentityHelper.GetInstance();
                if (userid.Text == "" || password.Password.ToString() == "")
                {
                }
                else
                {
                    var claims = await ih.CreateClaimsAsync(userid.Text, password.Password.ToString());//输入合法性验证

                    if (claims.IsAuthenticated && claims.User.Status == AppUserStatus.Enabled)
                    {
                        _claimsStored = claims;
                        SendClaimsEvent?.Invoke(claims);
                        Close();
                        ModernDialog.ShowMessage("登录成功", " ", MessageBoxButton.OK);
                    }
                    else if (claims.User != null && claims.User.Status == AppUserStatus.NotApproved)
                    {
                        ModernDialog.ShowMessage("已发送用户注册审批请求,请等待机构管理员审批", "注册成功", MessageBoxButton.OK);
                    }
                    else
                    {
                        Hide();
                        ModernDialog.ShowMessage("用户名或密码出错,或未通过管理员审批!", "登录失败", MessageBoxButton.OK);
                        Show();
                    }
                }
            }
        }