Ejemplo n.º 1
0
 public User(User u)
 {
     _username = u.UserName;
     _state = u.State;
     _nickname = u.NickName;
     _authLevel = u.AuthLevel;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// returns the internal User object corresponding to a user
 /// </summary>
 /// <param name="username">the email id of the user in question</param>
 /// <returns>the internal user object used to manage the user</returns>
 public User GetUser(string username)
 {
     foreach (User user in UserList)
     {
         if (username == user.UserName)
         {
             //found a user that is allowed.
             return user;
         }
     }
     User newUser = new User(username, "UnAuth", UserState.Invalid, UserAuthLevel.Unauthorized);
     return newUser;
 }
Ejemplo n.º 3
0
        //add user function to add to users.ini
        public bool AddUser(string username, string nickname, UserAuthLevel auth)
        {
            bool result = false;

            Logger.LogInformation("runtime add user request for " + username + "(" + nickname + ") " + auth.ToString());
            UserState state = UserState.Allowed;
            User newUser = new User(username, nickname, state, auth); //remotely added
            try
            {
                //todo(0) fix the obvious bug here (append and dont introdude a new line)
                StreamWriter writer = File.AppendText(SessionSettings.usersfile);
                writer.WriteLine(); //extra!
                writer.WriteLine(username + "|" + nickname + "|" + auth.ToString());
                writer.Flush();
                writer.Close();
                result = true;
            }
            catch (Exception ex)
            {
                Logger.LogInformation("error adding user to usersfile");
                Logger.LogException(ex);
                result = false;
            }
            return result;
        }