public ClientApplication(Network network, string username, User.AccessRights accessRights)
        {
            InitializeComponent();
            this.network = network;
            this.username = username;
            this.accessRights = accessRights;
            Agenda();

            User.AccessRights allRights = User.AccessRights.Leidinggevende | User.AccessRights.KantoorMedewerker;
            User.AccessRights viewRights = User.AccessRights.Kitter;

            if ((accessRights & allRights) != 0)
            {
                MessageBox.Show("Logged in as leidinggevende or kantoormedewerker");
            }
            if((accessRights & User.AccessRights.Leidinggevende) != 0)
            {
                MessageBox.Show("Logged in as leidinggevende");
                //Show tab only for leidinggevende
            }
            else if((accessRights & viewRights) != 0)
            {
                MessageBox.Show("Logged in as kitter");
                projectLijstTab.Hide();
                addUserButton.Hide();
                changeUserButton.Hide();
                removeUserButton.Hide();
                werkbonComboBox.Hide();
                addButon.Hide();
            }
        }
Exemplo n.º 2
0
 public AlterUser(User user)
 {
     this.user = user;
     InitializeComponent();
     if(user == null) //new user
         identifierLabel.Text = "Gebruiker Toevoegen";
     else //alter user
     {
         identifierLabel.Text = "Gebruiker Wijzigen";
         userNameTextBox.Text = user.username;
         userRightsComboBox.Text = user.accessRights.ToString();
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Check if the user exist, if not add the user to the users file.</summary>
        /// <param name="newUser">The new user to be added</param>
        public void AddUser(User newUser)
        {
            Boolean addUser = true;

            //Last check to prevent creating an user that already excists
            foreach (User user in server.users)
            {
                if (user.username.ToLower().Equals(newUser.username.ToLower()))
                {
                    addUser = false;
                    break;
                }
            }

            //if no duplicate has been found, newUser can be added to the userlist
            if (addUser)
                server.AddNewUser(newUser);
            Console.WriteLine("Succesfully created new user {0} with password {1}.", newUser.username, newUser.password);
        }
Exemplo n.º 4
0
 private void submintButton_Click(object sender, System.EventArgs e)
 {
     if(user == null)
     {
         switch(userRightsComboBox.Text)
         {
             case "Kitter":
                 user = new User(userNameTextBox.Text,passwordTextBox.Text.ToLower(),User.AccessRights.Kitter);
                 break;
             case "KantoorMedewerker":
                 user = new User(userNameTextBox.Text, passwordTextBox.Text.ToLower(), User.AccessRights.KantoorMedewerker);
                 break;
             case "Leidinggevende":
                 user = new User(userNameTextBox.Text, passwordTextBox.Text.ToLower(), User.AccessRights.Leidinggevende);
                 break;
         }
     }
     else
     {
         if(userNameTextBox.Text != "")
             user.username = userNameTextBox.Text;
         if(passwordTextBox.Text != "")
             user.password = passwordTextBox.Text;
         switch (userRightsComboBox.Text)
         {
             case "Kitter":
                 user.accessRights = User.AccessRights.Kitter;
                 break;
             case "KantoorMedewerker":
                 user.accessRights = User.AccessRights.KantoorMedewerker;
                 break;
             case "Leidinggevende":
                 user.accessRights = User.AccessRights.Leidinggevende;
                 break;
         }
     }
 }
Exemplo n.º 5
0
 public PacketAddUser(User user)
 {
     this.user = user;
 }
Exemplo n.º 6
0
 /// <summary>
 /// Check if username and password are correct and send a response.</summary>
 /// <param name="username">The username of the user</param>
 /// <param name="password">The password of the user</param>
 public void Login(string username, string password)
 {
     Console.WriteLine("Iemand probeert in te loggen als " + username + ", wachtwoord: " + password);
     //Actual login checking:
     foreach (User user in server.users)
     {
         if (user.username.ToLower().Equals(username.ToLower()))
         {
             if (PasswordHash.ValidatePassword(password, user.password))
             {
                 NetworkCommunication.SendPacket(new PacketLoginResponse(true, user.accessRights), stream);
                 Console.WriteLine("{0} succesfully logged in.", username);
                 this.user = user;
                 break;
             }
             else //wrong password
             {
                 Console.WriteLine("wrong password");
                 NetworkCommunication.SendPacket(new PacketLoginResponse(false, user.accessRights), stream);
                 break;
             }
         }
     }
 }
Exemplo n.º 7
0
 public void LoginResponse(bool loginOk, User.AccessRights accessRights)
 {
     this.loginOk = loginOk;
     this.accessRights = accessRights;
 }
Exemplo n.º 8
0
 public void AddUser(User user)
 {
     network.sendPacket(new PacketAddUser(user));
 }
 /// <summary>
 /// Add a new user the users file.</summary>
 /// <param name="newUser">The new user that will be added</param>
 public void AddNewUser(User newUser)
 {
     users.Add(newUser);
     FileIO.SaveUsers(users);
 }