Beispiel #1
0
        public void ServiceLimboConnections()
        {
            foreach (PlayerConnectionState player in limboConnections)
            {
                if (player.HasNewData())
                {
                    List <BasePacket> packetList = player.RetrieveData();
                    foreach (BasePacket packet in packetList)
                    {
                        LoginCredentials lc = packet as LoginCredentials;
                        if (lc != null && loginServerSocket != null)
                        {
                            UserAccountRequest uar = IntrepidSerialize.TakeFromPool(PacketType.UserAccountRequest) as UserAccountRequest;
                            uar.connectionId = player.tempId;
                            uar.password.Copy(lc.password);
                            uar.product_name.Copy("hungry hippos"); // TODO, configure product name
                            uar.username.Copy(lc.playerName);

                            loginServerSocket.Send(uar);
                            break;
                        }
                    }
                    IntrepidSerialize.ReturnToPool(packetList);
                }
            }
        }
        public async Task EditPhoneAsync(UserAccountRequest request)
        {
            using (var userRepository = new Repository <User>(_provider)) {
                var user = await userRepository.Get(x => x.UserName == request.Email).SingleAsync();

                user.Phone = request.Phone;
                userRepository.Update(user);
                userRepository.Commit();
            }
        }
        public async Task EditPasswordAsync(UserAccountRequest request)
        {
            using (var userRepository = new Repository <User>(_provider)) {
                var user = await userRepository.Get(x => x.UserName == request.Email).SingleAsync();

                user.Password = _passwordHasher.HashPassword(user, request.Password);
                userRepository.Update(user);
                userRepository.Commit();
            }
        }
        public async Task <IActionResult> Put([FromBody] UserAccountRequest request, [FromServices] IAuthenticationManager authentication)
        {
            if (request.Email != User.Identity.Name)
            {
                return(Json(ApiResponse.Failed(ApiErrorCode.ValidationError, "У текущего пользователя недостаточно прав")));
            }
            await authentication.EditPasswordAsync(request);

            return(Json(ApiResponse.Success(true)));
        }
Beispiel #5
0
        public void SendLoginRequest(string username, string password, string productname)
        {
            Console.WriteLine("send request: username: {0}\npassword: {1}\nproductname: {2}\n", username, password, productname);
            UserAccountRequest loginCredentials = (UserAccountRequest)IntrepidSerialize.TakeFromPool(PacketType.UserAccountRequest);

            loginCredentials.password.Copy(password);
            loginCredentials.username.Copy(username);
            loginCredentials.connectionId = 0;
            loginCredentials.product_name.Copy(productname);
            socket.Send(loginCredentials);
        }
 public void UserAccount(UserAccountRequest model, string UserId)
 {
     DataProvider.ExecuteNonQuery(GetConnection, "dbo.Users_UpdateAccount"
                                  , inputParamMapper : delegate(SqlParameterCollection paramCollection)
     {
         paramCollection.AddWithValue("@FirstName", model.FirstName);
         paramCollection.AddWithValue("@LastName", model.LastName);
         paramCollection.AddWithValue("@Id", UserId);
     }, returnParameters : delegate(SqlParameterCollection param)
     {
     }
                                  );
 }
        public WebAPIReponse SignIn([FromBody] UserAccountRequest userAccount)
        {
            try
            {
                AccountInfo mtsAccountInfo = new AccountInfo();
                mtsAccountInfo.UserID = userAccount.LoginAccount;
                PassWordHelper passWordHelper = new PassWordHelper(userAccount.LoginPassword);
                mtsAccountInfo.PassWord = passWordHelper.CrtPassWord();
                var userInfo = _usersService.Login(mtsAccountInfo);
                if (userInfo != null)
                {
                    // 校验密码,生成 Token
                    JwtAuthUtil   jwtAuthUtil = new JwtAuthUtil();
                    JwtAuthObject jwtAuthInfo = new JwtAuthObject
                    {
                        UserName = userInfo.UserID,
                    };
                    switch (userAccount.LoginPlatform)
                    {
                    case SoftPlatform.mtsToolCaliburn:
                        jwtAuthInfo.ExpiryDateTime = DateTime.Now.AddHours(12).ToString(); break;

                    case SoftPlatform.mtsToolLoggerCenter:
                        jwtAuthInfo.ExpiryDateTime = DateTime.Now.AddHours(4).ToString(); break;

                    case SoftPlatform.mtsToolsSchedule:
                        jwtAuthInfo.ExpiryDateTime = DateTime.Now.AddMinutes(15).ToString(); break;

                    case SoftPlatform.mtsToolsStudio:
                        jwtAuthInfo.ExpiryDateTime = DateTime.Now.AddHours(4).ToString(); break;

                    default: jwtAuthInfo.ExpiryDateTime = DateTime.Now.AddMinutes(5).ToString(); break;
                    }
                    string jwtToken = jwtAuthUtil.GenerateToken(jwtAuthInfo);
                    return(new WebAPIReponse(HttpStatusCode.OK, "OK", jwtToken));
                }
                return(new WebAPIReponse(HttpStatusCode.NonAuthoritativeInformation, "Access Denied"));
            }
            catch (Exception exception)
            {
                return(new WebAPIReponse(HttpStatusCode.PreconditionFailed, "Precondition Failed", exception.ToString()));
            }
        }
Beispiel #8
0
        private void ProcessUserAccountRequest(RequestSetup requestInProcess)
        {
            UserAccountRequest request   = requestInProcess.request as UserAccountRequest;
            PlayerSaveState    saveState = accountQuerier.GetPlayerSaveState(
                request.username.MakeString(),
                request.password.MakeString(),
                request.product_name.MakeString());

            UserAccountResponse response = (UserAccountResponse)IntrepidSerialize.TakeFromPool(PacketType.UserAccountRequest);

            response.connectionId   = request.connectionId;
            response.isValidAccount = saveState != null;
            if (saveState != null)
            {
                response.state = saveState;
            }

            ConnectionState cs = connections[requestInProcess.connectionId];

            cs.Send(response);
        }