コード例 #1
0
        /// <summary>
        /// Completion handler for a <see cref="LoginOperation"/>. If operation succeeds,
        /// it closes the window. If it has an error, we show an <see cref="ErrorWindow"/>
        /// and mark the error as handled. If it was not canceled, but login failed, it must
        /// have been because credentials were incorrect so we add a validation error to
        /// to notify the user.
        /// </summary>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (loginOperation.LoginSuccess)
            {
                this.parentWindow.Close();
            }
            else if (loginOperation.HasError)
            {
                ErrorWindow.CreateNew(loginOperation.Error);
                loginOperation.MarkErrorAsHandled();
            }
            else if (!loginOperation.IsCanceled)
            {
                this.loginInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
            }

            var userService = IoC.Resolve <IApplicationUserService>();

            userService.ApplicationUserRetrieved += (sender, e) =>
            {
                if (e.Value is ApplicationUser)
                {
                    ApplicationUser.CurrentUser = e.Value as ApplicationUser;
                }
            };

            userService.ApplicationUserRetrievalError += (sender, e) =>
            {
                WebContext.Current.Authentication.Logout(true);
                ErrorWindow.CreateNew("Error occured creating the application user");
            };
            userService.RetrieveApplicationUser(loginInfo.UserName);
        }
コード例 #2
0
    private void BtnWXLoginOnClick()
    {
        // AudioManager.Instance.PlaySound("button");
        if (Application.platform == RuntimePlatform.WindowsEditor)
        {
            string         acc            = SecurityUtils.AESEncrypt("WX-o2xMF1vxkphDaUP88lkypIYwN14E", kv[0], kv[1]);
            string         pwd            = SecurityUtils.AESEncrypt("123458", kv[0], kv[1]);
            LoginOperation loginOperation = new LoginOperation();
            LoginDto       loginDto       = loginOperation.regist(UnityEngine.Random.Range(1, 10000).ToString(), UnityEngine.Random.Range(1, 100000).ToString(), "123", "Default_" + UnityEngine.Random.Range(0, 7), "男", "123");

            if (loginDto != null)
            {
                //SaveLoginInfo();
                //登录成功 跳转场景
                PlayerCache.loginInfo = loginDto;
                UIManager.Instance.Clear();

                TcpSocketImpl.getInstance().init();
                ClientTcpIoMessage ioMessage = new ClientTcpIoMessage();
                ioMessage.methodName    = "";
                ioMessage.interfaceName = "";
                List <object> list = new List <object>(2);
                list.Add(loginDto.uid);
                list.Add(loginDto.secretKey);

                ioMessage.args = JsonMapper.ToJson(list);
                TcpSocketImpl.getInstance().async(ioMessage, 1, -100);
                XUIUtils.LoadSceneX((int)SceneType.Hall);
            }
        }
        else
        {
            loginByWX.LoginByWX();
        }
    }
コード例 #3
0
    public void StartWXLogin(WeiXinInfo info)
    {
        SetThirdLoginInfo("WX-" + info.openid, "123458", info.nickname, info.headimgurl, LoginType.WX);
        string sex = null;

        if (info.sex == "1")
        {
            sex = "男";
        }
        else
        {
            sex = "女";
        }
        string acc = SecurityUtils.AESEncrypt("WX-" + info.openid, kv[0], kv[1]);
        string pwd = SecurityUtils.AESEncrypt("123458", kv[0], kv[1]);
        //string[] msg = new string[] { "1", ((int)LoginType.WX).ToString(), acc, pwd, info.nickname, info.headimgurl, sex, Application.version };

        LoginOperation loginOperation = new LoginOperation();
        LoginDto       loginDto       = loginOperation.regist(info.openid, "123", "123", "123", "123", "123");

        if (loginDto != null)
        {
            //登录成功 跳转场景
            PlayerCache.loginInfo = loginDto;
            UIManager.Instance.Clear();
            XUIUtils.LoadSceneX((int)SceneType.Hall);
        }
        else
        {
            XUIMidMsg.QuickMsg("登录失败,请稍后再试!!!");
        }
    }
コード例 #4
0
ファイル: MainViewModel.cs プロジェクト: Surrog/atomic-rss
        private void loginOp_Completed(object sender, EventArgs e)
        {
            LoginOperation loginOp = (LoginOperation)sender;

            if (loginOp.HasError)
            {
                Debug.WriteLine("FAIL : " + loginOp.Error.Message);
                loginOp.MarkErrorAsHandled();
                return;
            }
            else if (!loginOp.LoginSuccess)
            {
                if (loginOp.Error != null)
                {
                    Debug.WriteLine("FAIL : " + loginOp.Error.Message);
                }
                return;
            }
            Debug.WriteLine("You're now logued ! " + WebContext.Current.Authentication.User.Identity.IsAuthenticated);
            LoginRegisterPageVisibility = Visibility.Collapsed;
            LogoutVisibility            = Visibility.Visible;
            if (!WebContext.Current.Authentication.User.IsInRole("Admin"))
            {
                UserPageVisibility = Visibility.Visible;
                CurrentPage        = "/Home";
            }
            else
            {
                AdminPageVisibility = Visibility.Visible;
                CurrentPage         = "/AdminPanel";
            }
        }
コード例 #5
0
        public ResultLogin LoginV2(LoginOperation option)
        {
            Handler handler = new Login.V2.HandlerLogin(option);

            handler.Invoke();
            return((ResultLogin)handler.Result);
        }
コード例 #6
0
    void Update()
    {
        // If user presses Space, then perform the login operation.
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Debug.Log("Starting login process...");

            LoginOperation.Create(LoginCriteria.Create("greg7", "asdf2")).ExecuteAsync(Callback);

            // Alternatively, executes the operation synchronously.
            //  This WILL block until the web operation is completed (sometimes it takes as long as ~250 frames), so asynchronous is preferred to prevent gameplay hiccups.
            //LoginOperationResult result = operation.Execute();

            Debug.Log("Finished login operation!");
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            RegisterOperationCriteria criteria = RegisterOperationCriteria.Builder.Create()
                                                 .Username("greg900563")
                                                 .Password("")
                                                 .Email("*****@*****.**")
                                                 .DateOfBirth(new DateTime(1989, 11, 25))
                                                 .Gender(RegistrationCriteriaGender.Male)
                                                 .ZipCode("52333").Build();

            RegisterOperation registerOperation = RegisterOperation.Create(criteria);
            registerOperation.ExecuteAsync(RegisterCallback);
        }
    }
コード例 #7
0
ファイル: LoginServiceTest.cs プロジェクト: emrahbasmaz/boat
        public void LoginOperation()
        {
            CustomerService service = new CustomerService();
            string          pass    = "******";

            byte[] bb = Encoding.UTF8.GetBytes(pass);

            RequestPersonalInformation request = new RequestPersonalInformation()
            {
                CUSTOMER_NAME     = "john",
                CUSTOMER_SURNAME  = "cluster",
                CUSTOMER_NUMBER   = 1,
                EMAIL             = "*****@*****.**",
                INSERT_USER       = "******",
                IDENTIFICATION_ID = 79945571838,
                PHONE_NUMBER      = "5357977315",
                UPDATE_USER       = "******",
                GENDER            = Enum.GetName(typeof(Enums.GENDER), 1),
                PASSWORD_HASH     = bb,
                PASSWORD_SALT     = bb,
                Header            = new Header
                {
                    Device         = (int)DeviceEnum.Device.WEB,
                    OperationTypes = (int)OperationType.OperationTypes.ADD,
                    RequestId      = Guid.NewGuid().ToString(),
                    ApiKey         = "U6l1hKzpZDrgfTaKxpQm3A/6raDiroAI7ueTgMNwhQs="
                }
            };

            LoginOperation op = new LoginOperation(request, service);

            op.Execute();

            Assert.IsTrue(op.baseResponseMessage.header.IsSuccess);
        }
コード例 #8
0
        public async Task <BaseResponseMessage> Login(RequestPersonalInformation request)
        {
            LoginOperation op = new LoginOperation(request, service);

            op.Execute();

            return(op.baseResponseMessage);
        }
コード例 #9
0
 private void LoginOperation_Completed(LoginOperation loginOperation)
 {
     LoginIndicator.IsBusy = false;
     if (loginOperation.LoginSuccess)
     {
         this.Content = new MainPage();
     }
 }
コード例 #10
0
 private void LoginOperation_Completed(LoginOperation loginOperation)
 {
     LoginIndicator.IsBusy = false;
     if (loginOperation.LoginSuccess)
     {
         this.Content = new MainPage();
     }
 }
コード例 #11
0
        private void LoginCallback(LoginOperation loginOperation)
        {
            if (loginOperation.LoginSuccess)
            {
                UpdateLoginState(true);
                RaiseEvent(LoggedIn);
                return;
            }

            RaiseEvent(LoginFailed);
        }
コード例 #12
0
ファイル: MainViewModel.cs プロジェクト: Surrog/atomic-rss
        private void login()
        {
            if (Email == null || Password == null)
            {
                error();
                return;
            }
            LoginOperation loginOp = WebContext.Current.Authentication.Login(new LoginParameters(email_, password_));

            loginOp.Completed += new EventHandler(loginOp_Completed);
        }
コード例 #13
0
ファイル: Login.aspx.cs プロジェクト: hoohd/hoohd2
    protected void Button_Click(object sender, EventArgs e)
    {
        string    strSQL = "select * from TabTeachers where UserID='" + TextBox1.Text + "'";
        DataTable dt     = new DataTable();

        dt = LoginOperation.GetDTFromDAL(strSQL);

        if (dt.Rows.Count == 1)
        {
            if (TextBox3.Text == Session["ValidateCode"].ToString())
            {
                if (dt.Rows[0]["UserPWD"].ToString() == TextBox2.Text)
                {
                    Session["userid"]   = dt.Rows[0]["UserID"].ToString();
                    Session["userrole"] = dt.Rows[0]["Role"].ToString();
                    Session["username"] = dt.Rows[0]["UserName"].ToString();
                    string Role = dt.Rows[0]["Role"].ToString();
                    switch (Role)
                    {
                    case "1":
                        Response.Redirect("AdminDefault.aspx");
                        break;

                    case "2":
                        Response.Redirect("AdminDefault.aspx");
                        break;

                    case "3":
                        Response.Redirect("AdminDefault.aspx");
                        break;

                    case "4":
                        Response.Redirect("Admin/AddNewTeacher.aspx");

                        break;
                    }
                }
                //}
                else
                {
                    Label3.Text = "密码不正确!";
                }
            }
            else
            {
                Label3.Text = "验证码错误";
            }
        }
        else
        {
            Label3.Text = "用户名不正确!";
        }
    }
コード例 #14
0
ファイル: LoginForm.xaml.cs プロジェクト: slieser/sandbox
 /// <summary>
 /// Completion handler for a <see cref="LoginOperation"/>. If operation succeeds,
 /// it closes the window. If it has an error, we show an <see cref="ErrorWindow"/>
 /// and mark the error as handled. If it was not canceled, but login failed, it must
 /// have been because credentials were incorrect so we add a validation error to
 /// to notify the user.
 /// </summary>
 private void LoginOperation_Completed(LoginOperation loginOperation) {
     if (loginOperation.LoginSuccess) {
         this.parentWindow.Close();
     }
     else if (loginOperation.HasError) {
         ErrorWindow.CreateNew(loginOperation.Error);
         loginOperation.MarkErrorAsHandled();
     }
     else if (!loginOperation.IsCanceled) {
         this.loginInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
     }
 }
コード例 #15
0
    void OnConnectionSuccess(Gamedonia.Rt.Events.Event evt)
    {
        Debug.Log ("Connected!!");

        LoginOperation lop = new LoginOperation();
        System.Random rnd = new System.Random();
        int val = rnd.Next (1,9999);

        lop.silent = Convert.ToString (val);

        lop.name = nameInput.text;
        GamedoniaRT.SharedInstance().SendOp(lop);
    }
コード例 #16
0
ファイル: AdminDefault.aspx.cs プロジェクト: hoohd/hoohd2
    protected void Page_Load(object sender, EventArgs e)

    {
        if (!IsPostBack)
        {
            Label1.Text = Session["userid"].ToString() + Session["username"].ToString() + "你好,你的权限为" + Session["userrole"].ToString();

            DataTable dt = LoginOperation.GetDTFromDAL("select distinct Department from TabTeachers");
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                DropDownList1.Items.Add(dt.Rows[i][0].ToString());
            }
        }
    }
コード例 #17
0
        /// <summary>
        ///     Submits the <see cref="LoginOperation"/> to the server
        /// </summary>
        private void LoginButton_Click(object sender, EventArgs e)
        {
            // If there was a validation error in a previously login attempt, clear it
            this.loginForm.ValidationSummary.Errors.Clear();

            if (this.loginForm.ValidateItem())
            {
                LoginOperation loginOperation = WebContext.Current.Authentication.Login(this.loginInfo.ToLoginParameters(), this.LoginOperation_Completed, null);

                this.BindUIToOperation(loginOperation);
                this.parentWindow.AddPendingOperation(loginOperation);
                this.lastLoginOperation = loginOperation;
            }
        }
コード例 #18
0
        public bool LoginOperation(RequestPersonalInformation request, out BaseResponseMessage response)
        {
            LoginOperation op = new LoginOperation(request);

            op.Execute();
            response = op.baseResponseMessage;

            if (!response.header.IsSuccess)
            {
                return(false);
            }

            return(true);
        }
コード例 #19
0
 /// <summary>
 ///     Handles <see cref="SubmitOperation.Completed"/> for a userRegistrationContext
 ///     operation. If there was an error, an <see cref="ErrorWindow"/> is
 ///     displayed to the user. Otherwise, this triggers a <see cref="LoginOperation"/>
 ///     that will automatically log in the just registered user
 /// </summary>
 private void RegistrationOperation_Completed(SubmitOperation asyncResult)
 {
     if (asyncResult.HasError)
     {
         ErrorWindow.CreateNew(asyncResult.Error);
         asyncResult.MarkErrorAsHandled();
         this.registerForm.BeginEdit();
     }
     else
     {
         LoginOperation loginOperation = WebContext.Current.Authentication.Login(this.registrationData.ToLoginParameters(), this.LoginOperation_Completed, null);
         this.BindUIToOperation(loginOperation);
         this.parentWindow.AddPendingOperation(loginOperation);
     }
 }
コード例 #20
0
        /// <summary>
        ///     Handles <see cref="LoginOperation.Completed"/> event for
        ///     the login operation that is sent right after a successful
        ///     userRegistrationContext. This will close the window. On the unexpected
        ///     event that this operation failed (the user was just added so
        ///     why wouldn't it be authenticated successfully) an
        ///     <see cref="ErrorWindow"/> is created and will display the
        ///     error message.
        /// </summary>
        /// <param name="loginOperation"></param>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            this.parentWindow.Close();

            if (loginOperation.HasError)
            {
                ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ApplicationStrings.ErrorLoginAfterRegistrationFailed, loginOperation.Error.Message));
                loginOperation.MarkErrorAsHandled();
            }
            else if (loginOperation.LoginSuccess == false)
            {
                // ApplicationStrings.ErrorBadUserNameOrPassword is the correct error message as operation succeeded but login failed
                ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ApplicationStrings.ErrorLoginAfterRegistrationFailed, ApplicationStrings.ErrorBadUserNameOrPassword));
            }
        }
コード例 #21
0
 /// <summary>
 /// Completion handler for a <see cref="LoginOperation"/>.
 /// If operation succeeds, it closes the window.
 /// If it has an error, it displays an <see cref="ErrorWindow"/> and marks the error as handled.
 /// If it was not canceled, but login failed, it must have been because credentials were incorrect so a validation error is added to notify the user.
 /// </summary>
 private void LoginOperation_Completed(LoginOperation loginOperation)
 {
     if (loginOperation.LoginSuccess)
     {
         this.parentWindow.DialogResult = true;
     }
     else if (loginOperation.HasError)
     {
         ErrorWindow.CreateNew(loginOperation.Error);
         loginOperation.MarkErrorAsHandled();
     }
     else if (!loginOperation.IsCanceled)
     {
         this.loginInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
     }
 }
コード例 #22
0
ファイル: CreateNewUser.xaml.cs プロジェクト: k0stya/quizApp
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (!loginOperation.IsCanceled)
            {

                if (loginOperation.HasError)
                {
                    ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorLoginAfterRegistrationFailed, loginOperation.Error.Message));
                    loginOperation.MarkErrorAsHandled();
                }
                else if (loginOperation.LoginSuccess == false)
                {
                    // The operation was successful, but the actual login was not
                    ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorLoginAfterRegistrationFailed, ErrorResources.ErrorBadUserNameOrPassword));
                }
            }
        }
コード例 #23
0
        private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            if (!WebContext.Current.Authentication.IsLoggingIn)
            {
                LoginOperation = WebContext.Current.Authentication.Login("demo", "demodemo@");
                LoginOperation.Completed += (s, ev) =>
                {
                    if (OnLoginOperationCompleted != null)
                        OnLoginOperationCompleted(this, null);
                };
            }
            else

            {
                MessageBox.Show("Δοκημάστε Σε λίγο να συνδεθήτε σαν Demo");
            }
        }
コード例 #24
0
ファイル: LoginPage.xaml.cs プロジェクト: ehsangfl/Samples
 private void OnLoginCompleted(LoginOperation obj)
 {
     LoginButton.IsEnabled = true;
     if (obj.HasError)
     {
         MessageBox.Show($"Login failed: {obj.Error.Message}");
         obj.MarkErrorAsHandled();
     }
     else
     {
         MessageBox.Show($"LoginSuccess: {obj.LoginSuccess}");
         if (obj.LoginSuccess)
         {
             this.NavigationService.Navigate(new MainPage());
         }
     }
 }
コード例 #25
0
        private void loginOp_Completed(object sender, EventArgs e)
        {
            LoginOperation loginOp = (LoginOperation)sender;

            if (loginOp.HasError)
            {
                Debug.WriteLine("FAIL : " + loginOp.Error.Message);
                loginOp.MarkErrorAsHandled();
                return;
            }
            else if (!loginOp.LoginSuccess)
            {
                Debug.WriteLine("YOU FAIL !");
                return;
            }
            Debug.WriteLine("You're now logued !");
        }
コード例 #26
0
    // Use this for initialization
    void Start()
    {
        LoginOperationResult result = LoginOperation.Create(LoginCriteria.Create("greg", "asdf")).Execute();

        switch (result.LoginOperationStatus)
        {
        case (LoginOperationStatus.Success):
            break;

        default:
            Debug.LogError("Could not log in!");
            return;
        }

        GetGroupsOperationResult getGroupsResult = GetGroupsOperation.Create(new GetGroupsOperationCriteria(result.AuthenticationToken)).Execute();

        getGroupsResult.PrintResultSetData();
    }
        public void When_writing_login_operation_it_must_be_correct()
        {
            // Arrange
            var operation = new LoginOperation();

            // Act
            byte[] buffer = PacketWriter.Write(operation, false);

            // Assert
            buffer.Should().BeEquivalentTo(new byte[]
            {
                2,
                ByteFor('0'),
                ByteFor('1'),
                ByteFor('\t'),
                3
            });
        }
コード例 #28
0
        /// <summary>
        /// Completion handler for the login operation that occurs after a successful
        /// registration and login attempt.  This will close the window. On the unexpected
        /// event that this operation failed (the user was just added so why wouldn't it
        /// be authenticated successfully) an  <see cref="ErrorWindow"/> is created and
        /// will display the error message.
        /// </summary>
        /// <param name="loginOperation">The <see cref="LoginOperation"/> that has completed.</param>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (!loginOperation.IsCanceled)
            {
                this.parentWindow.Close();

                if (loginOperation.HasError)
                {
                    ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorLoginAfterRegistrationFailed, loginOperation.Error.Message));
                    loginOperation.MarkErrorAsHandled();
                }
                else if (loginOperation.LoginSuccess == false)
                {
                    // The operation was successful, but the actual login was not
                    ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorLoginAfterRegistrationFailed, ErrorResources.ErrorBadUserNameOrPassword));
                }
            }
        }
コード例 #29
0
ファイル: LoginController.cs プロジェクト: ynosa/KanbanBoard
 public void OnLoginCompleted(LoginOperation operation)
 {
     if (operation.HasError)
     {
         viewOrchestrator.ChangeView(RegionNames.MAIN_REGION, "ErrorView", string.Format(viewOrchestrator.ParametrTemplate, "MESSAGE", operation.Error.Message));
         operation.MarkErrorAsHandled();
         return;
     }
     else if (!operation.LoginSuccess)
     {
         viewOrchestrator.ChangeView(RegionNames.MAIN_REGION, "ErrorView", string.Format(viewOrchestrator.ParametrTemplate, "MESSAGE", "Incorrect username or password!"));
         return;
     }
     else
     {
         viewOrchestrator.ChangeView(RegionNames.MAIN_REGION, "BoardsView");
         viewOrchestrator.ChangeView(RegionNames.HEADER_REGION, "StatusView", string.Format(viewOrchestrator.ParametrTemplate, "USERNAME", operation.User.Identity.Name));
     }
 }
コード例 #30
0
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            IsBusy = false;
            if (loginOperation.LoginSuccess)
            {
                ProductManager.Web.User lUser = loginOperation.User.Identity as ProductManager.Web.User;
                if (lUser.IsFreeze)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("用户已冻结", "用户已冻结!");
                    notifyWindow.Show();
                    return;
                }

                App app = Application.Current as App;
                app.UserInfo = new UserInfo();

                app.UserInfo.UserName       = lUser.UserName;
                app.UserInfo.UserAction     = lUser.RightDictionary;
                app.UserInfo.UserDepartment = lUser.Department;
                app.UserInfo.UserID         = lUser.UserID;
                app.UserInfo.DepartmentID   = lUser.DepartmentID;
                app.UserInfo.UserPassword   = lUser.Password;
                app.UserInfo.IsManager      = lUser.IsManager;

                if (app.UserInfo.UserPassword == Cryptography.MD5.GetMd5String("123456"))
                {
                    ModifyPasswrodWindow modifyPasswordWindow = new ModifyPasswrodWindow();
                    modifyPasswordWindow.Closed += modifyWindowClosed;
                    modifyPasswordWindow.Show();
                }
                else
                {
                    app.LogonUser(app.UserInfo.UserID, app.UserInfo.UserName);
                    FinishLogon(null);
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("用户名或密码错误", "用户名或密码错误");
                notifyWindow.Show();
            }
        }
コード例 #31
0
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            IsBusy = false;
            if (loginOperation.LoginSuccess)
            {
                ProductManager.Web.User lUser = loginOperation.User.Identity as ProductManager.Web.User;
                if (lUser.IsFreeze)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("用户已冻结", "用户已冻结!");
                    notifyWindow.Show();
                    return;
                }

                App app = Application.Current as App;
                app.UserInfo = new UserInfo();

                app.UserInfo.UserName = lUser.UserName;
                app.UserInfo.UserAction = lUser.RightDictionary;
                app.UserInfo.UserDepartment = lUser.Department;
                app.UserInfo.UserID = lUser.UserID;
                app.UserInfo.DepartmentID = lUser.DepartmentID;
                app.UserInfo.UserPassword = lUser.Password;
                app.UserInfo.IsManager = lUser.IsManager;

                if (app.UserInfo.UserPassword == Cryptography.MD5.GetMd5String("123456"))
                {
                    ModifyPasswrodWindow modifyPasswordWindow = new ModifyPasswrodWindow();
                    modifyPasswordWindow.Closed += modifyWindowClosed;
                    modifyPasswordWindow.Show();
                }
                else
                {
                    app.LogonUser(app.UserInfo.UserID, app.UserInfo.UserName);
                    FinishLogon(null);
                }
            }
            else
            {
                NotifyWindow notifyWindow = new NotifyWindow("用户名或密码错误", "用户名或密码错误");
                notifyWindow.Show();
            }
        }
コード例 #32
0
ファイル: PomaMobile.cs プロジェクト: chrooter/bkitpoma
        //private void btnLogin_Click(object sender, EventArgs e)
        //{
        //    FuncCallDelegate func = new FuncCallDelegate(_btnLogin_Click);
        //    func.BeginInvoke(null, null, null, null);
        //}

        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                updateSession(long.Parse(txtID.Text), txtPWD.Text);
            }
            catch (Exception ex)
            {
                log(ex.Message);
            }

            LoginOperation result = session.Login();

            if (result.OK)
            {
                log("Login successed: " + result.Result);
            }
            else
            {
                log(result.Message);
            }

            ConfigOperation config = session.Config();

            if (config.OK)
            {
                session.Interval = config.Interval;
                session.Schedule = config.Schedule;

                log("Interval: " + config.Interval + " s");
                string s = "Schedule: ";
                foreach (bool b in config.Schedule)
                {
                    s += b + ",";
                }
                log(s);
            }
            else
            {
                log("Interval: " + config.RawMessage);
            }
        }
コード例 #33
0
        public void Login_Succes()
        {
            Mock <IEncryptService> mockEncrypt = new Mock <IEncryptService>();

            mockEncrypt.Setup(x => x.Encrypt("successful")).Returns("successful");
            mockEncrypt.Setup(x => x.Decrypt(It.IsAny <String>(), It.IsAny <String>())).Returns("Password correct");
            Mock <IFileOperation> mockFile = new Mock <IFileOperation>();

            mockFile.Setup(x => x.ReadFromFile(It.IsAny <String>())).Returns(new User {
                UserName = "******", Password = "******"
            });

            LoginOperation loginOperation = new LoginOperation(mockEncrypt.Object, mockFile.Object);
            LoginRequest   loginRequest   = new LoginRequest {
                userName = "******", password = "******"
            };
            var result = loginOperation.Login(loginRequest);

            Assert.True(result.isSuccess);
        }
コード例 #34
0
        /// <summary>
        ///     Binds UI so that controls will look disabled and activity control will
        ///     be displaying while operation is in progress, and cancel button will
        ///     be enabled only while the login operation can be cancelled
        /// </summary>
        private void BindUIToOperation(LoginOperation loginOperation)
        {
            Binding isEnabledBinding        = loginOperation.CreateOneWayBinding("IsComplete");
            Binding isActivityActiveBinding = loginOperation.CreateOneWayBinding("IsComplete", new NotOperatorValueConverter());
            Binding isCancelEnabledBinding  = loginOperation.CreateOneWayBinding("CanCancel");

            this.activity.SetBinding(Activity.IsActiveProperty, isActivityActiveBinding);
            this.loginButton.SetBinding(Control.IsEnabledProperty, isEnabledBinding);
            this.loginForm.SetBinding(Control.IsEnabledProperty, isEnabledBinding);
            this.registerNow.SetBinding(Control.IsEnabledProperty, isEnabledBinding);

            // The correct binding for the cancel button would be
            // IsEnabled = loginOperation.CanCancel || loginOperation.IsComplete
            //
            // However, this is a binding to two distinct properties which is
            // not supported, so we bind solely to CanCancel and remove the binding
            // once the operation is complete with a callback
            this.loginCancel.SetBinding(Control.IsEnabledProperty, isCancelEnabledBinding);
            loginOperation.Completed += this.ReEnableCancelButton;
        }
コード例 #35
0
        private void LoginOperationCompleted(LoginOperation lo)
        {
            StrNotifications       = String.Empty;
            this.EnableLoginButton = true;
            if (!lo.HasError)
            {
                if (lo.LoginSuccess)
                {
                    if (WebContext.Current.User.IsAuthenticated)
                    {
                        StrUser     = String.Empty;
                        StrPassword = String.Empty;
                        CurrentUser = WebContext.Current.User;
                        //MessageBox.Show(CurrentUser.Roles.First());
                    }
                    this.RegionManager.RequestNavigate("HeaderRegion", "HeaderUserControl");

                    try
                    {
                        this.ModuleManager.LoadModule("ProyectosModule");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    this.ModuleManager.LoadModuleCompleted += ModuleManager_LoadModuleCompleted;
                    this.RegionManager.RequestNavigate("MainContentRegion", "ProyectosMainUserControl");
                    this.RegionManager.RequestNavigate("MainMenuRegion", "MainMenuUserControl");
                }
                else
                if (!lo.LoginSuccess)
                {
                    MessageBox.Show("Usuario o Contraseña Incorrectos.");
                }
            }
            else
            {
                MessageBox.Show("Error de Autenticación. Consulte al Soporte técnico del Sistema.");
            }
        }
コード例 #36
0
        /// <summary>
        ///     Handles <see cref="LoginOperation.Completed"/> event. If operation
        ///     succeeds, it closes the window. If it has an error, we show an <see cref="ErrorWindow"/>
        ///     and mark the error as handled. If it was not canceled, succeded but login failed,
        ///     it must have been because credentials were incorrect so we add a validation error
        ///     to notify the user
        /// </summary>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (loginOperation.LoginSuccess)
            {
                this.parentWindow.Close();
            }
            else
            {
                if (loginOperation.HasError)
                {
                    ErrorWindow.CreateNew(loginOperation.Error);
                    loginOperation.MarkErrorAsHandled();
                }
                else if (!loginOperation.IsCanceled)
                {
                    this.loginForm.ValidationSummary.Errors.Add(new ValidationSummaryItem(ErrorResources.ErrorBadUserNameOrPassword));
                }

                this.loginForm.BeginEdit();
            }
        }
コード例 #37
0
        public void Login_UserNotFound()
        {
            Mock <IEncryptService> mockEncrypt = new Mock <IEncryptService>();

            mockEncrypt.Setup(x => x.Encrypt("successful")).Returns("successful");
            mockEncrypt.Setup(x => x.Decrypt(It.IsAny <String>(), It.IsAny <String>())).Returns("successful");
            Mock <IFileOperation> mockFile = new Mock <IFileOperation>();

            mockFile.Setup(x => x.ReadFromFile(It.IsAny <String>())).Returns(new User {
                Password = "******"
            });

            LoginOperation loginOperation = new LoginOperation(mockEncrypt.Object, mockFile.Object);
            LoginRequest   loginRequest   = new LoginRequest {
                userName = "******", password = "******"
            };
            var result = loginOperation.Login(loginRequest);

            Assert.False(result.isSuccess);
            Assert.Equal("User Not Found", result.message);
        }
コード例 #38
0
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            IsBusy = false;
            App app = Application.Current as App;

            if (loginOperation.LoginSuccess)
            {
                DocumentManager.Web.User lUser = loginOperation.User.Identity as DocumentManager.Web.User;

                if (lUser.ExpireDay == -1100)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("注册错误", "注册信息丢失, 请与 管理员 联系");
                    notifyWindow.Show();
                    return;
                }
                else if (lUser.ExpireDay < 0)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("应用程序已经过期", "应用程序已经过期" + lUser.ExpireDay.ToString() + "天, 请与 管理员 联系");
                    notifyWindow.Show();
                    return;
                }
                else if (lUser.ExpireDay < 30)
                {
                    NotifyWindow notifyWindow = new NotifyWindow("过期", "还有" + lUser.ExpireDay + "天, 应用程序即将过期,请与 管理员 联系");
                    notifyWindow.Show();
                }

                app.MainPageViewModel.User = lUser;
                app.SuccessLogon();
            }
            else
            {

                NotifyWindow notifyWindow = new NotifyWindow("用户名或密码错误", "用户名或密码错误");
                notifyWindow.Show();
                return;
            }
        }
コード例 #39
0
        private void loginOperation_Completed(LoginOperation loginOperation)
        {
            Action<bool> callBack = loginOperation.UserState as Action<bool>;
            if (!loginOperation.HasError && loginOperation.LoginSuccess)
            {

                if(callBack!=null)
                {
                    callBack.Invoke(true);
                }

            }
            else
            {
                if (loginOperation.HasError)
                {
                    loginOperation.MarkErrorAsHandled();
                }
                if (callBack != null)
                {
                    callBack.Invoke(false);
                }
            }
        }
コード例 #40
0
ファイル: ShellViewModel.cs プロジェクト: unicloud/AFRP
        /// <summary>
        /// <see cref="LoginOperation"/> 的完成处理程序。
        /// 如果操作成功,则关闭窗口。
        /// 如果发生错误,则显示 <see cref="ErrorWindow"/> 并将错误标记为已处理。
        /// 如果未取消操作但是登录失败,则一定是因为凭据不正确,因此添加验证错误以通知用户。
        /// </summary>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (loginOperation.LoginSuccess)
            {
                // 设置当前用户
                var user = this._service.EntityContainer.GetEntitySet<Users>().SingleOrDefault(u => u.UserName.ToLower() == WebContext.Current.User.Name.ToLower());
                // 获取应用列表
                this.AppList = this._service.EntityContainer.GetEntitySet<Applications>()
                    .Where(a => a.ApplicationName != "UniCloud" && a.ApplicationName != "AFRP").ToList();
                // 设置当前用户应用与功能的可用性
                this.AppList.ForEach(a =>
                {
                    var userAppRoles = user.UserInRoles.Select(ur => ur.Roles).Where(r => r.Application == a);
                    a.IsValid = userAppRoles.Any();
                    a.FunctionItems.Where(fi => fi.IsLeaf).ToList().ForEach(f =>
                        f.IsValid = userAppRoles.SelectMany(r => r.FunctionsInRoles)
                        .Where(fr => fr.FunctionItemID == f.FunctionItemID && fr.IsValid).Any());
                });

                this.IsLogined = true;
            }
            else if (loginOperation.HasError)
            {
                ErrorWindow.CreateNew(loginOperation.Error);
                loginOperation.MarkErrorAsHandled();
            }
            else if (!loginOperation.IsCanceled)
            {
                this.LogInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
            }
        }
コード例 #41
0
ファイル: LoginForm.xaml.cs プロジェクト: resadzacina/SCMS
        /// <summary>
        /// Completion handler for a <see cref="LoginOperation"/>. If operation succeeds,
        /// it closes the window. If it has an error, we show an <see cref="ErrorWindow"/>
        /// and mark the error as handled. If it was not canceled, but login failed, it must
        /// have been because credentials were incorrect so we add a validation error to
        /// to notify the user.
        /// </summary>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (loginOperation.LoginSuccess)
            {
                this.parentWindow.Close();
            }
            else if (loginOperation.HasError)
            {
                if (loginOperation.Error.Message.Contains("MembershipProvider"))
                {
                    var mess = new MessageWindow( "Please check database configuration, it is not accessible" );
                    mess.Show();
                }
                else
                    ErrorWindow.CreateNew( loginOperation.Error );

                loginOperation.MarkErrorAsHandled();
            }
            else if (!loginOperation.IsCanceled)
            {
                this.loginInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
            }
        }
コード例 #42
0
 private void LoginOperation_Completed(LoginOperation loginOperation)
 {
     if (loginOperation.LoginSuccess)
     {
         if (LoginComplete != null)
             LoginComplete(this, new LoginOperationEventArgs(loginOperation));
     }
     else
     {
         if (loginOperation.HasError)
         {
             if (LoginComplete != null)
                 LoginComplete(this, new LoginOperationEventArgs(loginOperation, loginOperation.Error));
             loginOperation.MarkErrorAsHandled();
         }
         else if (!loginOperation.IsCanceled)
         {
             if (LoginComplete != null)
             {
                 //var ex = new Exception(CommonResources.BadUserOrPassword);
                 var ex = new Exception("Tên đăng nhập hoặc mật khẩu hoặc sai");
                 LoginComplete(this, new LoginOperationEventArgs(ex));
             }
         }
         else
         {
             if (LoginComplete != null)
                 LoginComplete(this, new LoginOperationEventArgs(loginOperation));
         }
     }
 }
コード例 #43
0
 /// <summary>
 /// Completion handler for a <see cref="LoginOperation"/>.
 /// If operation succeeds, it closes the window.
 /// If it has an error, it displays an <see cref="ErrorWindow"/> and marks the error as handled.
 /// If it was not canceled, but login failed, it must have been because credentials were incorrect so a validation error is added to notify the user.
 /// </summary>
 private void LoginOperation_Completed(LoginOperation loginOperation)
 {
     if (loginOperation.LoginSuccess)
     {
         //loads the current user
         ViewModels.ViewModelLocator.CurrentUserViewModelStatic.LoadCurrentUser();
         this.parentWindow.DialogResult = true;
     }
     else if (loginOperation.HasError)
     {
         ErrorWindow.CreateNew(loginOperation.Error);
         loginOperation.MarkErrorAsHandled();
     }
     else if (!loginOperation.IsCanceled)
     {
         this.loginInfo.ValidationErrors.Add(new ValidationResult(ErrorResources.ErrorBadUserNameOrPassword, new string[] { "UserName", "Password" }));
     }
 }
コード例 #44
0
        /// <summary>
        /// Обработчик завершения для операции входа возникает после успешной регистрации и попытки входа.
        /// Закрывает окно. Если операция завершилась ошибкой, сообщение будет отображено в окне <see cref="ErrorWindow"/>.
        /// </summary>
        /// <param name="loginOperation">Завершаемая операция <see cref="LoginOperation"/>.</param>
        private void LoginOperation_Completed(LoginOperation loginOperation)
        {
            if (!loginOperation.IsCanceled)
            {
                this.parentWindow.DialogResult = true;

                if (loginOperation.HasError)
                {
                    ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorLoginAfterRegistrationFailed, loginOperation.Error.Message));
                    loginOperation.MarkErrorAsHandled();
                }
                else if (loginOperation.LoginSuccess == false)
                {
                    // Операция выполнена успешно, но вход не выполнен
                    ErrorWindow.CreateNew(string.Format(System.Globalization.CultureInfo.CurrentUICulture, ErrorResources.ErrorLoginAfterRegistrationFailed, ErrorResources.ErrorBadUserNameOrPassword));
                }
            }
        }
コード例 #45
0
 public LoginOperationEventArgs(LoginOperation loginOp)
     : base(null)
 {
     LoginOp = loginOp;
 }
コード例 #46
0
		private void OnResetPasswordCompletedStep2(LoginOperation operation)
		{
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null || !operation.LoginSuccess)
			{
				MessageBoxEx.ShowError("Reset password", errorStatus, null);
				return;
			}
		}
コード例 #47
0
		private void OnRegisterCompletedStep2(LoginOperation operation)
		{
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null || !operation.LoginSuccess)
			{
				MessageBoxEx.ShowError("Register account", errorStatus, null);
				return;
			}

			App.Model.UserServices.CheckOKtoSetProperty();
			App.Model.UserServices.User.OptInUpdates = (bool)x_OptInUpdates.IsChecked;
			App.Model.UserServices.SaveUser(OnRegisterCompletedStep3, null/*userState*/);
		}
コード例 #48
0
		private void OnSigninCompleted(LoginOperation operation)
		{
			x_Signin.IsEnabled = true;
			string errorStatus = operation.CheckErrorStatus();
			if (errorStatus != null || !operation.LoginSuccess)
			{
				x_SignInErrorStatus.Text = (errorStatus != null ? errorStatus : g_TryAgainMessage);
				x_SignInErrorStatus.Visibility = Visibility.Visible;
				return;
			}

			x_SignInErrorStatus.Text = null;
			x_SignInErrorStatus.Visibility = Visibility.Collapsed;
			DialogResult = MessageBoxResult.OK;
		}
コード例 #49
0
 public LoginOperationEventArgs(LoginOperation loginOp, Exception ex)
     : base(ex)
 {
     LoginOp = loginOp;
 }