コード例 #1
0
        public async Task <LoginResult> AuthenticateUser(PlayerCredentials request)
        {
            var authenticator = new PlayerAuthenticator();
            var password      = rsa.Decrypt(request.Password, false);

            var result = await authenticator.AuthenticatePlayer(request.PlayerNickname, password);

            var response = new LoginResult {
                UserID = result
            };

            if (result.HasValue)
            {
                lock (Connections.connections) {
                    if (!Connections.connections.ContainsKey(result.Value))
                    {
                        Connections.connections.Add(result.Value, this);
                        Authenticated = true;
                        Userid        = result.Value;
                    }
                    else
                    {
                        response.FailureReason = FailureReason.AlreadyLoggedIn;
                        response.UserID        = null;
                    }
                }
            }
            else
            {
                response.FailureReason = FailureReason.InvalidCredentials;
            }

            return(response);
        }
コード例 #2
0
        public async Task <RegisterPlayerResponse> RegisterPlayer(PlayerCredentials request)
        {
            var registrator = new PlayerAuthenticator();
            var password    = rsa.Decrypt(request.Password, false);

            var id = await registrator.RegisterPlayer(request.PlayerNickname, password);

            return(new RegisterPlayerResponse {
                PlayerID = id
            });
        }