Exemplo n.º 1
0
        /// <summary>
        /// The lobby client on on login complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
        {
            this.Dispatcher.BeginInvoke(new Action(
                                            () =>
            {
                ConnectBox.Visibility = Visibility.Hidden;
                ConnectBoxProgressBar.IsIndeterminate = false;
            }));
            switch (results)
            {
            case LoginResults.Success:
                this.SetStateOnline();
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (GameManager.Get().GameCount == 0)
                    {
                        TabCustomGames.Focus();
                    }
                    else
                    {
                        TabCommunityChat.Focus();
                    }
                }));
                break;

            default:
                this.SetStateOffline();
                break;
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// The fire login complete.
 /// </summary>
 /// <param name="result">
 /// The result.
 /// </param>
 private void FireLoginComplete(LoginResults result)
 {
     if (this.OnLoginComplete != null)
     {
         this.OnLoginComplete.Invoke(this, result);
     }
 }
Exemplo n.º 3
0
        public async Task <LoginResults> Login(LoginInput input)
        {
            var result        = new Status();
            var returnResults = new LoginResults {
                status = new Status(), userDetail = new UserViewModel()
            };

            try
            {
                var password = Helpers.StringCipher.Encrypt(input.Password);
                var user     = _context.Users.Where(x => x.UserName == input.UserName && x.Password == password && !x.Deleted).FirstOrDefault();
                if (user != null)
                {
                    returnResults.userDetail = user.Adapt <UserViewModel>();
                    result = new Status {
                        StatusCode = 200, StatusDisplay = "Logged in Successfully", StatusValue = true
                    };
                }
                else
                {
                    result = new Status {
                        StatusCode = 198, StatusDisplay = "UserName and Password does not match", StatusValue = false
                    };
                }
            }
            catch (Exception ex)
            {
                result = new Status {
                    StatusCode = 500, StatusDisplay = ex.Message, StatusValue = false
                };
            }
            returnResults.status = result;
            return(returnResults);
        }
Exemplo n.º 4
0
 void LobbyClient_OnLoginComplete(object sender, LoginResults results)
 {
     lock (_gameListLocker)
     {
         Log.Info("Connected");
     }
 }
Exemplo n.º 5
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (ValidateInput())
     {
         User u;
         try
         {
             LoginResults choice = ubll.Login(txtName.Text.Trim(), txtPwd.Text.Trim(), out u);
             if (choice == LoginResults.Success)
             {
                 this.Visible = false;
                 FrmMain fm = new FrmMain(u);
                 fm.Show();
             }
             else if (choice == LoginResults.PwdError)
             {
                 MessageBox.Show("密码错误");
             }
             else
             {
                 MessageBox.Show("无效账号");
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// The lobby client on on login complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
        {
            this.Dispatcher.BeginInvoke(new Action(() => ConnectBox.Visibility = Visibility.Hidden));
            switch (results)
            {
            case LoginResults.Success:
                this.SetStateOnline();
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    TabCommunityChat.Focus();
                })).Completed += (o, args) => Task.Factory.StartNew(() => {
                    Thread.Sleep(15000);
                    this.Dispatcher.Invoke(new Action(()
                                                      =>
                    {
                        var s =
                            SubscriptionModule.Get
                                ().IsSubscribed;
                        if (s != null && s == false)
                        {
                            this.SubMessage.Visibility = Visibility.Visible;
                        }
                    }));
                });
                break;

            default:
                this.SetStateOffline();
                break;
            }
        }
Exemplo n.º 7
0
 private void LobbyClientOnOnLoginComplete(object sender ,LoginResults results)
 {
     switch (results)
     {
         case LoginResults.Success:
             Canceled = false;
             ReconnectTimer.Dispose();
             break;
         case LoginResults.Failure:
             Canceled = true;
             ReconnectTimer.Dispose();
             break;
     }
     Dispatcher.Invoke(new Action(() =>
     {
         switch(results)
         {
             case LoginResults.Success:
                 if (Program.LobbyClient.DisconnectedBecauseConnectionReplaced) Canceled = false;
                 Connected = true;
                 this.Close();
                 break;
             case LoginResults.Failure:
                 this.Close();
                 break;
         }
     }));
 }
Exemplo n.º 8
0
 void LobbyClient_OnLoginComplete(object sender, LoginResults results)
 {
     lock (timer)
     {
         Log.Info("Connected");
         isConnected = true;
     }
 }
Exemplo n.º 9
0
        public async Task <JsonResult> GetUserbyLogin([FromBody] Login input)
        {
            apiUrl = Config.ApiUrl + "http://localhost:56492/api/accounts";
            // localUrl = Config.LocalUrl + "https://localhost:44346/api/Login";

            Object returnResults = new object();

            //object LocalreturnResults = new object();
            try
            {
                if (Config.debugMode && input.UserName == "admin" && input.Password == "admin")
                {
                    var results = new LoginResults {
                        status = new Status(), userDetail = new UserViewModel()
                    };
                    results.status = new Status {
                        StatusValue = true, StatusCode = 200, StatusDisplay = "Logged in"
                    };
                    results.userDetail = new UserViewModel
                    {
                        UserName = input.UserName,
                        ID       = 99999,
                        RoleID   = 1,
                        AcceptedTermsAndConditions = true,
                        IsFirstTimeLogin           = false
                    };
                    returnResults = results;
                    await SigninWeb(input, results.userDetail);
                }
                else
                {
                    var stringContent = new StringContent(Newtonsoft.Json.JsonConvert.SerializeObject(input), System.Text.Encoding.UTF8, "application/json");
                    using (HttpCustomGetClientConnect client = new HttpCustomGetClientConnect(apiUrl))
                    {
                        HttpResponseMessage response = await client.PostAsync(apiUrl, stringContent);

                        if (response.IsSuccessStatusCode)
                        {
                            var data = await response.Content.ReadAsStringAsync();

                            var result = Newtonsoft.Json.JsonConvert.DeserializeObject <LoginResults>(data);
                            returnResults = Newtonsoft.Json.JsonConvert.DeserializeObject <LoginResults>(data);
                            await SigninWeb(input, result.userDetail);
                        }
                        else
                        {
                            returnResults = null;
                        }
                    }
                }
            }
            catch (Exception _ex)
            {
                Debug.Print(_ex.Message);
            }
            return(new JsonResult(new { result = returnResults, sessionTimeout = Config.SessionTimeout }));
        }
Exemplo n.º 10
0
 private void LobbyClientOnLoginComplete(object sender, LoginResults results)
 {
     if (results != LoginResults.Success) return;
     Dispatcher.Invoke(new Action(() =>
     {
         TextBoxUserName.IsReadOnly = true;
         TextBoxUserName.Text = Program.LobbyClient.Me.UserName;
     }));
 }
Exemplo n.º 11
0
 /// <summary>
 /// The fire login complete.
 /// </summary>
 /// <param name="result">
 /// The result.
 /// </param>
 private void FireLoginComplete(LoginResults result)
 {
     Log.Info("Firing login complete");
     if (this.OnLoginComplete != null)
     {
         Log.Info("Fired login complete");
         this.OnLoginComplete.Invoke(this, result);
     }
 }
Exemplo n.º 12
0
 private void LobbyClientOnLoginComplete(object sender, LoginResults results)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         CheckBoxIsLocalGame.IsChecked = false;
         CheckBoxIsLocalGame.IsEnabled = true;
         TextBoxUserName.IsEnabled     = false;
         TextBoxUserName.Text          = Program.LobbyClient.Me.UserName;
     }));
 }
Exemplo n.º 13
0
 private void LobbyClientOnLoginComplete(object sender, LoginResults results)
 {
     if (results != LoginResults.Success)
     {
         return;
     }
     Dispatcher.Invoke(new Action(() =>
     {
         TextBoxUserName.IsReadOnly = true;
         TextBoxUserName.Text       = Program.LobbyClient.Me.UserName;
     }));
 }
Exemplo n.º 14
0
 private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
 {
     if (!Dispatcher.CheckAccess())
     {
         Dispatcher.Invoke(new Action(() => this.LobbyClientOnOnLoginComplete(sender, results)));
         return;
     }
     if (results == LoginResults.Success)
     {
         this.IsEnabled = true;
         IsOffline      = false;
     }
 }
Exemplo n.º 15
0
        /// <summary>
        /// The lobby client on on login complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
        {
            this.Dispatcher.BeginInvoke(new Action(() => ConnectBox.Visibility = Visibility.Hidden));
            switch (results)
            {
            case LoginResults.Success:
                this.SetStateOnline();
                this.Dispatcher.BeginInvoke(new Action(() => TabCommunityChat.Focus()));
                break;

            default:
                this.SetStateOffline();
                break;
            }
        }
Exemplo n.º 16
0
 private void LobbyClientOnLoginComplete(object sender, LoginResults results)
 {
     if (results != LoginResults.Success)
     {
         return;
     }
     Dispatcher.Invoke(new Action(() =>
     {
         CheckBoxIsLocalGame.IsChecked = false;
         CheckBoxIsLocalGame.IsEnabled = true;
         LabelIsLocalGame.IsEnabled    = true;
         TextBoxUserName.IsReadOnly    = true;
         TextBoxUserName.Text          = Program.LobbyClient.Me.UserName;
     }));
 }
Exemplo n.º 17
0
        /// <summary>
        /// The lobby client on on login complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
        {
            this.Dispatcher.BeginInvoke(new Action(
                                            () =>
            {
                ConnectBox.Visibility = Visibility.Hidden;
                ConnectBoxProgressBar.IsIndeterminate = false;
            }));
            switch (results)
            {
            case LoginResults.Success:
                this.SetStateOnline();
                this.Dispatcher.BeginInvoke(new Action(() =>
                {
                    if (GameManager.Get().GameCount == 0)
                    {
                        TabCustomGames.Focus();
                    }
                    else
                    {
                        TabCommunityChat.Focus();
                    }
                })).Completed += (o, args) => Task.Factory.StartNew(() =>
                {
                    Thread.Sleep(15000);
                    this.Dispatcher.Invoke(new Action(()
                                                      =>
                    {
                        var s =
                            SubscriptionModule.Get
                                ().IsSubscribed;
                        if (s != null && s == false)
                        {
                            if (showedSubscriptionMessageOnce == false)
                            {
                                ShowSubMessage();
                                showedSubscriptionMessageOnce = true;
                            }
                        }
                    }));
                });
                break;

            default:
                this.SetStateOffline();
                break;
            }
        }
Exemplo n.º 18
0
 public void GetLoginResult(LoginResults resultado)
 {
     if (resultado == LoginResults.UsuarioEncontrado)
     {
         MenuPrincipal ventanaprincipal = new MenuPrincipal();
         ventanaprincipal.Show();
     }
     else if (resultado == LoginResults.NoExisteUrsuario)
     {
         MessageBox.Show("No existe usuario");
     }
     else
     {
         MessageBox.Show("Verifica tu contraseña");
     }
 }
Exemplo n.º 19
0
        private async Task <JsonResult> DoLoginAsync(string userNameOrEmailOrPhone, string password)
        {
            if (string.IsNullOrWhiteSpace(userNameOrEmailOrPhone))
            {
                return(AjaxHelper.JsonResult(HttpStatusCode.BadRequest, "用户名不能为空"));//400
            }
            if (string.IsNullOrWhiteSpace(password))
            {
                return(AjaxHelper.JsonResult(HttpStatusCode.BadRequest, "password参数不能为空"));
            }

            //登录错误次数过多要锁定账户
            LoginResults result = await _userService.CheckUserPasswordAsync(userNameOrEmailOrPhone, password);

            if (result == LoginResults.Success)
            {
                var user = await _userService.GetUserByUserNameOrEmailOrPhoneAsync(userNameOrEmailOrPhone);

                string token = Guid.NewGuid().ToString();
                await LoginManager.LoginAsync(token, user.Id);

                //获取当前用户的角色
                var roles = await _roleService.GetRolesByUserIdAsync(user.Id);

                await LoginManager.SaveCurrentUserRolesAsync(roles.Select(i => i.Name).ToArray(), user.Id);

                //获取当前用户的权限
                var permissions = await _permissionService.GetPermissionsByUserIdAsync(user.Id);

                await LoginManager.SaveCurrentUserPermissionsAsync(permissions.Select(i => i.Name).ToArray(), user.Id);

                LoginManager.ResetErrorLogin(LoginErrorTimes_Prefix, userNameOrEmailOrPhone);
                return(AjaxHelper.JsonResult(HttpStatusCode.OK, "成功", token));//200
            }
            if (result == LoginResults.NotExist)
            {
                return(AjaxHelper.JsonResult(HttpStatusCode.NotFound, "用户不存在"));//404
            }
            if (result == LoginResults.PassWordError)
            {
                await LoginManager.IncreaseErrorLoginAsync(LoginErrorTimes_Prefix, userNameOrEmailOrPhone);

                return(AjaxHelper.JsonResult(HttpStatusCode.NotAcceptable, "用户名或密码错误"));     //406
            }
            return(AjaxHelper.JsonResult(HttpStatusCode.BadGateway, "未知的result:" + result)); //502
        }
Exemplo n.º 20
0
        //#####################################################################################
        // 수신된 메세지 처리

        private void WhenRspLogin(NetMessageStream msg)
        {
            LoginResults loginResult = (LoginResults)msg.ReadInt32();

            if (loginResult == LoginResults.Success)
            {
                this.LoginName = m_tryName;
            }

            // 로그인 성공여부 저장
            this.IsOnLogin = (loginResult == LoginResults.Success);

            // 로그인 콜백 호출
            if (m_loginCallback != null)
            {
                m_loginCallback(loginResult);
                m_loginCallback = null;
            }
        }
Exemplo n.º 21
0
        void LobbyClientOnLoginComplete(object sender, LoginResults results)
        {
            Log.InfoFormat("Lobby Login Complete {0}", results);
            switch (results)
            {
            case LoginResults.ConnectionError:
                _isLoggingIn = false;
                DoErrorMessage("Could not connect to the server.");
                break;

            case LoginResults.Success:
                LoginFinished(LoginResult.Success, DateTime.Now, "");
                break;

            case LoginResults.Failure:
                LoginFinished(LoginResult.Failure, DateTime.Now, "Username/Password Incorrect.");
                break;
            }
            _isLoggingIn = false;
        }
Exemplo n.º 22
0
 private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
 {
     this.UpdateIsSubbed();
 }
Exemplo n.º 23
0
 void LobbyClient_OnLoginComplete(object sender, LoginResults results)
 {
     lock (_gameListLocker)
     {
         Log.Info("Connected");
     }
 }
Exemplo n.º 24
0
        /// <summary>
        /// The lobby client on on login complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
        {
            this.Dispatcher.BeginInvoke(new Action(() => ConnectBox.Visibility = Visibility.Hidden));
            switch (results)
            {
                case LoginResults.Success:
                    this.SetStateOnline();
                    this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (GameManager.Get().GameCount == 0)
                                TabCustomGames.Focus();
                            else
                                TabCommunityChat.Focus();

                        })).Completed += (o, args) => Task.Factory.StartNew(() =>
                        {
                            Thread.Sleep(15000);
                            this.Dispatcher.Invoke(new Action(()
                                                              =>
                                {
                                    var s =
                                        SubscriptionModule.Get
                                            ().IsSubscribed;
                                    if (s != null && s == false)
                                        ShowSubMessage();
                                }));
                        });
                    break;
                default:
                    this.SetStateOffline();
                    break;
            }
        }
Exemplo n.º 25
0
        private void WhenReceiveLoginResult(LoginResults result)
        {
            this.timer_update.Stop();


            if (result == LoginResults.Success)
            {
                SequenceToNext();
            }
            else if (result == LoginResults.Fail_AlreadyLogin)
            {
                MessageBox.Show("이미 로그인 상태인 계정입니다.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result == LoginResults.Fail_NotUser)
            {
                var selection = MessageBox.Show("존재하지않는 계정입니다.\n현재 기입된 정보로 등록하시겠습니까?", "Error!",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (selection == DialogResult.Yes)
                {
                    if (this.colorDialog_userColor.ShowDialog() == DialogResult.OK)
                    {
                        Color color = this.colorDialog_userColor.Color;

                        if (color.R >= 100 || color.G >= 100 || color.B >= 100)
                        {
                            // 회원가입 요청
                            m_client.SignDirector.Register(this.textBox_name.Text, this.textBox_password.Text,
                                                           color,
                                                           this.WhenReceiveRegisterResult);

                            this.timer_update.Start();


                            // UI 활성화 안되게 함.
                            return;
                        }
                        else
                        {
                            MessageBox.Show("색이 너무 어둡습니다.\nRGB 값 중 하나라도 100 이상이여야 합니다.", "Error!",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("색을 선택해주셔야 합니다.", "Error!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (result == LoginResults.Fail_WrongPassword)
            {
                MessageBox.Show("비밀번호가 틀립니다.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result == LoginResults.Fail_DifferentVersion)
            {
                MessageBox.Show("클라이언트의 버전이 서버와 다릅니다.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result == LoginResults.Fail_ServerNotReady)
            {
                MessageBox.Show("아직 서버가 준비 중 입니다.\n잠시후 다시 시도해주세요.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("로그인 실패.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            EnableUI();
        }
Exemplo n.º 26
0
 private void LobbyClientOnLoginComplete(object sender, LoginResults results)
 {
     if (results != LoginResults.Success) return;
     Dispatcher.Invoke(new Action(() =>
         { 
             CheckBoxIsLocalGame.IsChecked = false;
             CheckBoxIsLocalGame.IsEnabled = true;
             LabelIsLocalGame.IsEnabled = true;
             TextBoxUserName.IsReadOnly = true;
             TextBoxUserName.Text = Program.LobbyClient.Me.UserName;
         }));
     
 }
        public void MemberLoginWithCorrectUserNameAndPwd()
        {
            _story = new Story("Login with UserName and Password");

            _story.AsA("User")
              .IWant("to be able to login ")
              .SoThat("I can use features");

            _story.WithScenario("login with a correct username and password")
                .Given("Create a new with old password", () =>
                {
                    _Uobject = _utils.CreateUserObject("Eunge Liu",true);

                    _oldpassword = "******";

                    _newpassword = "******";

                    _membershipApi.Save(_Uobject, _oldpassword, "123Hello");

                    createdObjectIds.Add(_Uobject.UserId);

                })
                .When("I login", () =>
                {
                    _ret = _membershipApi.Login(_Uobject.UserName, _oldpassword);
                })
                .Then("The User can get Successful Logon",
                        () =>
                        {
                            _ret.ShouldEqual(LoginResults.Successful);
                        });

            this.CleanUp();
        }
Exemplo n.º 28
0
        void LobbyClientOnLoginComplete(object sender, LoginResults results)
        {
            switch (results)
                {
                    case LoginResults.ConnectionError:
                        UpdateLoginStatus("");
                        _isLoggingIn = false;
                        DoErrorMessage("Could not connect to the server.");
                        StopSpinning();

                        break;
                    case LoginResults.Success:
                        LoginFinished(LoginResult.Success, DateTime.Now,"");
                        break;
                    case LoginResults.Failure:
                        LoginFinished(LoginResult.Failure, DateTime.Now,"Username/Password Incorrect.");
                        break;
                }
                _isLoggingIn = false;
        }
Exemplo n.º 29
0
 void LobbyClient_OnLoginComplete(object sender, LoginResults results)
 {
     lock (timer)
     {
         Log.Info("Connected");
         isConnected = true;
     }
 }
Exemplo n.º 30
0
 public LoginResult(LoginResults result, Customer customer = null)
 {
     this.Result   = result;
     this.Customer = customer;
 }
Exemplo n.º 31
0
        /// <summary>
        /// Performs execution of the command
        /// </summary>
        protected override void ProcessRecord()
        {
            try
            {
                // create a new connection. This will overwrite any existing
                // connection that is already established
                NebConnection connection = new NebConnection();
                connection.Logger = new PowerShellLogger(this);

                // add support for the default parameter '-Verbose'
                if (MyInvocation.BoundParameters.ContainsKey("Verbose"))
                {
                    connection.Logger.LogLevel = LogSeverity.Verbose;
                }

                // add support for the default parameter '-Debug'
                if (MyInvocation.BoundParameters.ContainsKey("Debug"))
                {
                    connection.Logger.LogLevel = LogSeverity.Debug;
                }

                NetworkCredential credential = ParameterSetName == @"UserName"
                    ? new NetworkCredential(UserName, Password)
                    : new NetworkCredential(Credential.UserName, Credential.Password);

                LoginResults loginResults = connection.Login(credential.UserName, credential.Password);

                WriteVerbose(loginResults.Message);
                WriteVerbose(loginResults.Organization);

                // login was successful so we can store the connection as
                // a global variable
                SessionState.PSVariable.Set(
                    new PSVariable("NebulonConnection",
                                   connection,
                                   ScopedItemOptions.AllScope));

                WriteObject(connection);
            }
            catch (AggregateException exceptions)
            {
                foreach (Exception ex in exceptions.InnerExceptions)
                {
                    ErrorRecord record = new ErrorRecord(
                        ex,
                        ex.GetType().ToString(),
                        ErrorCategory.NotSpecified,
                        null);

                    WriteError(record);
                }
            }
            catch (Exception ex)
            {
                ErrorRecord record = new ErrorRecord(
                    ex,
                    ex.GetType().ToString(),
                    ErrorCategory.NotSpecified,
                    null);

                WriteError(record);
            }
        }
Exemplo n.º 32
0
 void LobbyClient_OnLoginComplete(object sender, LoginResults results)
 {
     isConnected = true;
 }
Exemplo n.º 33
0
 private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
 {
     this.UpdateIsSubbed();
 }
Exemplo n.º 34
0
        //#####################################################################################
        // 수신된 메세지 처리

        private NetMessage WhenReqLogin(ServerVisitor client, NetMessageStream msg)
        {
            string userName = msg.ReadData <string>();


            LoginResults loginResult = LoginResults.Success;


            // 로그인을 받을 수 있는 상태이면
            if (this.CanLogin)
            {
                string password    = msg.ReadData <string>();
                string versionText = Utility.Version.Zero.ToString();
                if (!msg.EndOfStream)
                {
                    versionText = msg.ReadData <string>();
                }
                Utility.Version clientVersion = new Utility.Version(versionText);


                // 클라이언트 버전이 서버버전과 같은지 확인
                if (Application.ProductVersion == clientVersion)
                {
                    // 회원여부 확인 및 비밀번호 얻기
                    bool   isMember     = m_accountList.ContainsKey(userName);
                    string realPassword = "";

                    if (isMember)
                    {
                        realPassword = m_accountList[userName].Password;
                    }


                    // 회원이 아니면 실패
                    if (isMember == false)
                    {
                        loginResult = LoginResults.Fail_NotUser;
                    }
                    // 비밀번호가 틀리면 실패
                    else if (password != realPassword)
                    {
                        loginResult = LoginResults.Fail_WrongPassword;
                    }
                    // 이미 접속된 유저와 이름이 중복되면 실패
                    else if (m_loginUserList.Any((user) => user.Value.Name == userName))
                    {
                        loginResult = LoginResults.Fail_AlreadyLogin;
                    }


                    // 로그인 성공시
                    if (loginResult == LoginResults.Success)
                    {
                        // 접속자 목록에 추가
                        m_loginUserList.Add(client.ID, new GamePlayer()
                        {
                            Name = userName
                        });


                        // 로그인 사실을 모두에게 알림
                        NetMessageStream loginNotice = new NetMessageStream();
                        loginNotice.WriteData(userName);

                        this.NoticeDelegate(loginNotice.CreateMessage((int)MessageTypes.Ntf_UserLogin));
                    }
                }
                else
                {
                    // 클라이언트의 버전과 서버의 버전이 다르므로 접속불가
                    loginResult = LoginResults.Fail_DifferentVersion;
                }
            }
            else
            {
                // 로그인을 받을 수 없음
                loginResult = LoginResults.Fail_ServerNotReady;
            }


            // 로그
            Utility.Logger.GetInstance().Log(string.Format("\"{0}\"님이 로그인을 시도했습니다. 결과 : {1}",
                                                           userName, loginResult.ToString()));


            // 로그인 결과 전송
            NetMessageStream writer = new NetMessageStream();

            writer.WriteData((int)loginResult);

            return(writer.CreateMessage((int)MessageTypes.Rsp_Login));
        }
Exemplo n.º 35
0
 private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
 {
     Dispatcher.Invoke(new Action(() =>
     {
         switch (results)
         {
             case LoginResults.Success:
                 Connected = true;
                 ConnectBox.Visibility = Visibility.Collapsed;
                 break;
             case LoginResults.Failure:
                 MessageBox.Show(
                     "Reconnect failed. Logging out.", "OCTGN", MessageBoxButton.OK, MessageBoxImage.Error);
                 this.CloseDownShop(false);
                 break;
         }
     }));
 }
Exemplo n.º 36
0
        /// <summary>
        /// The lobby client on on login complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
        {
            this.Dispatcher.BeginInvoke(new Action(
                () =>
                {
                    ConnectBox.Visibility = Visibility.Hidden;
                    ConnectBoxProgressBar.IsIndeterminate = false;
                }));
            switch (results)
            {
                case LoginResults.Success:
                    this.SetStateOnline();
                    this.Dispatcher.BeginInvoke(new Action(() =>
                        {
                            if (GameManager.Get().GameCount == 0)
                                TabCustomGames.Focus();
                            else
                                TabCommunityChat.Focus();

                        }));
                    break;
                default:
                    this.SetStateOffline();
                    break;
            }
        }
Exemplo n.º 37
0
 void LobbyClient_OnLoginComplete(object sender, LoginResults results)
 {
     isConnected = true;
 }
Exemplo n.º 38
0
 private void ClientOnOnLoginComplete(object sender, LoginResults results)
 {
     this.Reconnect();
 }
Exemplo n.º 39
0
 private async Task CreateLoginHistory(Guid?userId, string userName, string domainName, bool superUser, LoginResults result)
 {
     await DataContext.Database.ExecuteSqlInterpolatedAsync($"INSERT INTO dbo.UserLoginHistory (UserId, UserName, DomainName, IsSuperUser, LoginResult, HistoryDate) VALUES ({(object)userId ?? DBNull.Value}, {userName}, {domainName}, {superUser}, {(int)result}, {DateTime.UtcNow})");
 }
Exemplo n.º 40
0
 /// <summary>
 /// The lobby client on on login complete.
 /// </summary>
 /// <param name="sender">
 /// The sender.
 /// </param>
 /// <param name="results">
 /// The results.
 /// </param>
 private void LobbyClientOnOnLoginComplete(object sender, LoginResults results)
 {
     this.Dispatcher.BeginInvoke(new Action(() => ConnectBox.Visibility = Visibility.Hidden));
     switch (results)
     {
         case LoginResults.Success:
             this.SetStateOnline();
             this.Dispatcher.BeginInvoke(new Action(() => TabCommunityChat.Focus()));
             break;
         default:
             this.SetStateOffline();
             break;
     }
 }
 public CustomerLoginResults(LoginResults result)
 {
     this.Result = result;
 }
Exemplo n.º 42
0
 /// <summary>
 /// The fire login complete.
 /// </summary>
 /// <param name="result">
 /// The result.
 /// </param>
 private void FireLoginComplete(LoginResults result)
 {
     Log.Info("Firing login complete");
     if (this.OnLoginComplete != null)
     {
         Log.Info("Fired login complete");
         this.OnLoginComplete.Invoke(this, result);
     }
 }
Exemplo n.º 43
0
        public async Task <LoginResults> GoogleLogin(GoogleRegisterViewModel input)
        {
            var result        = new Status();
            var returnResults = new LoginResults {
                status = new Status(), userDetail = new UserViewModel()
            };

            try
            {
                var user = new User {
                    FirstName = input.givenName, LastName = input.familyName, Email = input.email, RoleID = 2, Source = Helpers.Constants.SOURCE_GOOGLE, UserName = input.email
                };
                var existUsers = await _context.Users.Where(x => x.Email == input.email).ToListAsync();

                if (existUsers.Count > 0)
                {
                    var valid = existUsers.Where(x => x.Deleted == false).FirstOrDefault();
                    if (valid != null)
                    {
                        user = valid;
                    }
                    else
                    {
                        throw new Exception("Given email is restricted, please use another email");
                    }
                }
                var password = Helpers.StringCipher.Encrypt("Password*123");

                //ENCRYPTS PASSWORD
                if (user.ID == 0)
                {
                    user.Password         = password;
                    user.IsFirstTimeLogin = true;
                    _context.Users.Add(user);
                    await _context.SaveChangesAsync();
                }
                if (user != null)
                {
                    var googleRegister = input.Adapt <GoogleRegister>();
                    googleRegister.googleid    = input.id;
                    googleRegister.accessToken = input.authentication.accessToken;
                    googleRegister.idToken     = input.authentication.idToken;
                    googleRegister.User        = user;
                    googleRegister.UserId      = user.ID;
                    _context.GoogleRegisters.Add(googleRegister);
                    await _context.SaveChangesAsync();

                    returnResults.userDetail = user.Adapt <UserViewModel>();
                    result = new Status {
                        StatusCode = 200, StatusDisplay = "Logged in Successfully", StatusValue = true
                    };
                }
                else
                {
                    result = new Status {
                        StatusCode = 198, StatusDisplay = "UserName and Password does not match", StatusValue = false
                    };
                }
            }
            catch (Exception ex)
            {
                result = new Status {
                    StatusCode = 500, StatusDisplay = ex.Message, StatusValue = false
                };
            }
            returnResults.status = result;
            return(returnResults);
        }
Exemplo n.º 44
0
        private void WhenReceiveLoginResult(LoginResults result)
        {
            this.timer_update.Stop();


            if (result == LoginResults.Success)
            {
                SequenceToNext();
            }
            else if (result == LoginResults.Fail_AlreadyLogin)
            {
                MessageBox.Show("이미 로그인 상태인 계정입니다.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result == LoginResults.Fail_NotUser)
            {
                var selection = MessageBox.Show("존재하지않는 계정입니다.\n현재 기입된 정보로 등록하시겠습니까?", "Error!",
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (selection == DialogResult.Yes)
                {
                    if (this.colorDialog_userColor.ShowDialog() == DialogResult.OK)
                    {
                        Color color = this.colorDialog_userColor.Color;

                        if (color.R >= 100 || color.G >= 100 || color.B >= 100)
                        {
                            SHA256CryptoServiceProvider sha256 = new SHA256CryptoServiceProvider();
                            byte[] hashByteArray;
                            string hashString  = string.Empty;
                            string plainString = this.textBox_password.Text;

                            hashByteArray = sha256.ComputeHash(Encoding.UTF8.GetBytes(plainString));

                            foreach (byte b in hashByteArray)
                            {
                                hashString += String.Format("{0:x2}", b);
                            }

                            // 회원가입 요청
                            m_client.SignDirector.Register(this.textBox_name.Text, hashString,
                                                           color,
                                                           this.WhenReceiveRegisterResult);

                            this.timer_update.Start();


                            // UI 활성화 안되게 함.
                            return;
                        }
                        else
                        {
                            MessageBox.Show("색이 너무 어둡습니다.\nRGB 값 중 하나라도 100 이상이여야 합니다.", "Error!",
                                            MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                    else
                    {
                        MessageBox.Show("색을 선택해주셔야 합니다.", "Error!",
                                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else if (result == LoginResults.Fail_WrongPassword)
            {
                MessageBox.Show("비밀번호가 틀립니다.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result == LoginResults.Fail_DifferentVersion)
            {
                MessageBox.Show("클라이언트의 버전이 서버와 다릅니다.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else if (result == LoginResults.Fail_ServerNotReady)
            {
                MessageBox.Show("아직 서버가 준비 중 입니다.\n잠시후 다시 시도해주세요.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                MessageBox.Show("로그인 실패.", "Error!",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            EnableUI();
        }
Exemplo n.º 45
0
        /// <summary>
        /// The login finished.
        /// </summary>
        /// <param name="success">
        /// The login results
        /// </param>
        /// <param name="message">
        /// The message.
        /// </param>
        private void LoginFinished(LoginResults success, string message)
        {
            if (this.inLoginDone)
            {
                return;
            }

            this.inLoginDone = true;
            Trace.TraceInformation("Login finished.");
            Dispatcher.BeginInvoke(
                (Action)(() =>
                    {
                        spLogin.IsEnabled = true;
                                                this.isLoggingIn = false;
                                                switch (success)
                                                {
                                                    case LoginResults.Success:
                                                        Prefs.Password = cbSavePassword.IsChecked == true
                                                                             ? passwordBox1.Password.Encrypt()
                                                                             : string.Empty;
                                                        Prefs.Username = textBox1.Text;
                                                        Prefs.Nickname = textBox1.Text;
                                                        spLogin.Visibility = Visibility.Collapsed;
                                                        lineSplit.Visibility = Visibility.Collapsed;
                                                        break;
                                                    default:
                                                        DoErrorMessage(message);
                                                        Program.LobbyClient.Stop();
                                                        spLogin.Visibility = Visibility.Visible;
                                                        break;
                                                }

                        this.inLoginDone = false;
                    }),
                new object[] { });
        }
Exemplo n.º 46
0
        void LobbyClientOnLoginComplete(object sender, LoginResults results)
        {
            Log.InfoFormat("Lobby Login Complete {0}",results);
                if (_isLoggingIn)
                {
                    switch (results)
                    {
                        case LoginResults.ConnectionError:

                            _isLoggingIn = false;
                            DoErrorMessage("Could not connect to the server.");
                            break;
                        case LoginResults.Success:
                            LoginFinished(LoginResult.Success, DateTime.Now, "");
                            break;
                        case LoginResults.Failure:
                            LoginFinished(LoginResult.Failure, DateTime.Now, "Username/Password Incorrect.");
                            break;
                    }
                    _isLoggingIn = false;
                }
        }
Exemplo n.º 47
0
        /// <summary>
        /// Fires when the lobby login request is complete.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="results">
        /// The results.
        /// </param>
        private void LobbyClientOnLoginComplete(object sender, LoginResults results)
        {
            var mess = string.Empty;
            switch (results)
            {
                case LoginResults.ConnectionError:
                    mess = "Could not connect to the server.";
                    break;
                case LoginResults.Success:
                    mess = string.Empty;
                    break;
                case LoginResults.Failure:
                    mess = "Unknown failure.";
                    break;
                case LoginResults.FirewallError:
                    mess = "This program is being blocked by a firewall on your pc.";
                    break;
                case LoginResults.AuthError:
                    mess = "Your username or password was incorrect.";
                    break;
            }

            this.isLoggingIn = false;
            this.LoginFinished(results, mess);
        }
Exemplo n.º 48
0
 /// <summary>
 /// The fire login complete.
 /// </summary>
 /// <param name="result">
 /// The result.
 /// </param>
 private void FireLoginComplete(LoginResults result)
 {
     if (this.OnLoginComplete != null)
     {
         this.OnLoginComplete.Invoke(this, result);
     }
 }
Exemplo n.º 49
0
 private void LobbyClientOnLoginComplete(object sender, LoginResults results)
 {
     Dispatcher.Invoke(new Action(() =>
         {
             CheckBoxIsLocalGame.IsChecked = false;
             CheckBoxIsLocalGame.IsEnabled = true;
             TextBoxUserName.IsEnabled = false;
             TextBoxUserName.Text = Program.LobbyClient.Me.UserName;
         }));
 }