示例#1
0
 public bool UpdateUserPassword(string username, string newpass)
 {
     try
     {
         User usr = User.LoadByUsername(username);
         usr.SetPassword(newpass, Constants.HTTP_AUTH_REALM);
         usr.Update();
     }
     catch (Exception e)
     {
         EventController.TriggerEvent(new ErrorOccuredEvent(e));
         Log.Error(e);
         return(false);
     }
     return(true);
 }
示例#2
0
        public static User Create(string username, string firstname, string lastname, string password, string email, Extension extension, UserRight[] rights)
        {
            Log.Trace("Creating new user with username " + username);
            if (LoadByUsername(username) != null)
            {
                throw new Exception("Unable to create user, one already exists with that username.");
            }
            User ret = new User();

            ret.UserName  = username;
            ret.FirstName = firstname;
            ret.LastName  = lastname;
            ret.SetPassword(password, Constants.HTTP_AUTH_REALM);
            ret.UserExtension = extension;
            ret.Rights        = rights;
            ret.Email         = email;
            Connection conn = ConnectionPoolManager.GetConnection(typeof(User));

            ret = (User)conn.Save(ret);
            conn.CloseConnection();
            return(ret);
        }
示例#3
0
 public static User Create(string username, string firstname, string lastname, string password,string email, Extension extension,UserRight[] rights)
 {
     Log.Trace("Creating new user with username " + username);
     if (LoadByUsername(username)!=null)
         throw new Exception("Unable to create user, one already exists with that username.");
     User ret = new User();
     ret.UserName = username;
     ret.FirstName = firstname;
     ret.LastName = lastname;
     ret.SetPassword(password, Constants.HTTP_AUTH_REALM);
     ret.UserExtension = extension;
     ret.Rights = rights;
     ret.Email = email;
     Connection conn = ConnectionPoolManager.GetConnection(typeof(User));
     ret = (User)conn.Save(ret);
     conn.CloseConnection();
     return ret;
 }