Example #1
0
        private static void TreatEditRequest(Socket socket, EditRequest editRequest)
        {
            switch (editRequest.TypeOfEdit)
            {
            case TypesEdit.Users:
                if (UsersInfos.GetRankOfUser(MyServer.Clients.GetUser(socket).UID) > editRequest.NewRankOfUser && UsersInfos.GetRankOfUser(MyServer.Clients.GetUser(socket).UID) > UsersInfos.GetRankOfUser(editRequest.UserToEdit))
                {
                    PromoteUser(editRequest.UserToEdit, editRequest.NewRankOfUser);
                    List <User> tmpU = new List <User>
                    {
                        UsersInfos.GetUser(editRequest.UserToEdit)
                    };
                    MyServer.SendObject(new RequestAnswer(tmpU, true), socket);
                    MyServer.Log.Warn($"User promoted { editRequest.UserToEdit} to " + editRequest.NewRankOfUser.ToString());
                }
                else
                {
                    MyServer.Log.Warn($"Promoting the user {editRequest.UserToEdit} to {editRequest.NewRankOfUser.ToString()} failed !");
                }
                break;

            case TypesEdit.Musics:
                if (MyServer.Clients.GetUser(socket).Rank > Rank.User)
                {
                    Indexation.ModifyElement(editRequest.ObjectToEdit as Element, editRequest.NewName, editRequest.NewGenres);
                    MyServer.Log.Warn($"The musics {editRequest.NewName} has been edited !");
                }
                else
                {
                    MyServer.Log.Warn($"The musics {editRequest.NewName } couldn't be edited");
                }
                break;
            }
        }
Example #2
0
 public static void PromoteUser(string UID, Rank rank)
 {
     UsersInfos.SetRankOfUser(UID, rank);
     if (MyServer.Clients.IsConnected(UID))
     {
         var userUpdated = UsersInfos.GetUser(UID);
         new EditUserReport(true, userUpdated).Send(MyServer.Clients.GetSocket(UID));
     }
 }
        public void GetUserTest()
        {
            Authentification.AuthentificationService a = new Authentification.AuthentificationService();
            a.SetupAuth();
            a.SignupUser(new Utility.Network.Users.CryptedCredentials("User1", "abc"));

            var getuser = UsersInfos.GetUser("abc");

            Assert.AreEqual(true, getuser.Name == "User1");
            Assert.AreEqual(true, getuser.UID == "abc");

            var getuser2 = UsersInfos.GetUser("abC");

            Assert.AreEqual(true, getuser2 == null);
        }
 private static void Edituser(Socket socket, EditRequest editRequest)
 {
     if (UsersInfos.GetRankOfUser(Program.MyServer.Clients.GetUser(socket).UID) > editRequest.NewRankOfUser && UsersInfos.GetRankOfUser(Program.MyServer.Clients.GetUser(socket).UID) > UsersInfos.GetRankOfUser(editRequest.UserToEdit))
     {
         Program.PromoteUser(editRequest.UserToEdit, editRequest.NewRankOfUser);
         List <User> tmpU = new List <User>
         {
             UsersInfos.GetUser(editRequest.UserToEdit)
         };
         (new RequestAnswer(tmpU, true)).Send(socket);
         Program.MyServer.Log.Warn($"User promoted { editRequest.UserToEdit} to " + editRequest.NewRankOfUser.ToString());
     }
     else
     {
         Program.MyServer.Log.Warn($"Promoting the user {editRequest.UserToEdit} to {editRequest.NewRankOfUser.ToString()} failed !");
     }
 }
Example #5
0
        public static void PromoteUser(string UID, Rank rank)
        {
            UsersInfos.SetRankOfUser(UID, rank);
            if (MyServer.Clients.IsConnected(UID))
            {
                var userUpdated = UsersInfos.GetUser(UID);
                MyServer.SendObject(new EditUserReport(true, userUpdated), MyServer.Clients.GetSocket(UID));
            }

            //User tmpUser = MyServer.Clients.GetUser(UID);
            //if (tmpUser != null)
            //{
            //    tmpUser.Rank = rank;
            //    Socket tmpSocket = MyServer.Clients.GetSocket(UID);
            //    MyServer.Clients.Remove(tmpSocket);
            //    MyServer.Clients.AddUser(tmpUser, tmpSocket);
            //    MyServer.SendObject(new EditUserReport(true, MyServer.Clients.GetUser(UID)), MyServer.Clients.GetSocket(UID));
            //}
        }