Beispiel #1
0
 /// <summary>
 /// Method for managing register of new user.
 /// </summary>
 /// <param name="username">Username</param>
 /// <param name="password">Password</param>
 /// <param name="rights">User rights</param>
 private void RegisterUser(string username, string password, UserRightsEnum rights)
 {
     if (Client.Register(username, password, rights))
     {
         ToggleControls();
     }
 }
        /// <summary>
        /// Method to register new user
        /// </summary>
        /// <returns></returns>
        private User RegisterUser()
        {
            string         username;
            string         password;
            UserRightsEnum rights = UserRightsEnum.None;

            username = BinaryReader.ReadString();
            password = BinaryReader.ReadString();
            rights   = (UserRightsEnum)BinaryReader.ReadInt32();

            if (Users.Any(u => u.Username == username))
            {
                BunaryWriter.Write(string.Format(Constants.USERNAME_ALREADY_IN_USE, username));
                return(AuthenticateUser());
            }
            else
            {
                User newUser = new User(username, password, rights);
                lock (Users)
                {
                    Users.Add(newUser);
                }

                string message = string.Format(Constants.USER_SUCCESSFULLY_REGISTERED, username);
                ProcessMessage(message);
                BunaryWriter.Write(message);

                return(newUser);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Method for registering new users.
        /// </summary>
        /// <param name="username">Username</param>
        /// <param name="password">Password</param>
        /// <param name="rights">User Rights</param>
        /// <returns></returns>
        internal bool Register(string username, string password, UserRightsEnum rights)
        {
            BinaryWriter.Write((int)ActionEnum.Register);
            BinaryWriter.Write(username);
            BinaryWriter.Write(password.GetHash());
            BinaryWriter.Write((int)rights);

            string response = BinaryReader.ReadString();

            ProcessMessage(response);

            return(response.Equals(string.Format(Constants.USER_SUCCESSFULLY_REGISTERED, username)));
        }
        /// <summary>
        /// Method for registering new users.
        /// </summary>
        /// <param name="username">Username</param>
        /// <param name="password">Password</param>
        /// <param name="rights">User Rights</param>
        /// <returns></returns>
        internal bool Register(string username, string password, UserRightsEnum rights)
        {
            BinaryWriter.Write((int)ActionEnum.Register);
            BinaryWriter.Write(username);
            BinaryWriter.Write(password.GetHash());
            BinaryWriter.Write((int)rights);

            string response = BinaryReader.ReadString();
            ProcessMessage(response);

            return response.Equals(string.Format(Constants.USER_SUCCESSFULLY_REGISTERED, username));
        }
Beispiel #5
0
 /// <summary>
 /// General constructor
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <param name="rights"></param>
 public User(string username, string password, UserRightsEnum rights)
 {
     this.Username = username;
     this.Password = password;
     this.Rights   = rights;
 }
Beispiel #6
0
 /// <summary>
 /// General constructor
 /// </summary>
 /// <param name="username"></param>
 /// <param name="password"></param>
 /// <param name="rights"></param>
 public User(string username, string password, UserRightsEnum rights)
 {
     this.Username = username;
     this.Password = password;
     this.Rights = rights;
 }
 /// <summary>
 /// Method for managing register of new user.
 /// </summary>
 /// <param name="username">Username</param>
 /// <param name="password">Password</param>
 /// <param name="rights">User rights</param>
 private void RegisterUser(string username, string password, UserRightsEnum rights)
 {
     if (Client.Register(username, password, rights))
     {
         ToggleControls();
     }
 }