Exemplo n.º 1
0
 internal static void DeleteUser(UserInfo userAdapter)
 {
     UserInfoDao dao = new UserInfoDao();
     UserInfo user = dao.FindByGuid(userAdapter.Guid);
     if (user != null)
     {
         using (Transaction tx = new Transaction())
         {
             dao.Delete<UserInfo>(user);
             tx.Commit();
         }
         System.Web.Security.Membership.DeleteUser(user.Username);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Finds the membership information based upon the username
        /// </summary>
        /// <param name="p"></param>
        /// <returns></returns>
        public static MembershipUserWrapper FindByUsername(String username)
        {
            MembershipUser user = System.Web.Security.Membership.GetUser(username);
            UserInfo info = new UserInfoDao().FindByUsername(username);

            //Check if the asp.net membership account is orphaned, if so, delete it
            if ((user != null) && (info == null))
            {
                System.Web.Security.Membership.DeleteUser(user.UserName);
                user = null;
            }

            //Check if the gooeycms account is orphaned, if so, delete it
            if ((user == null) && (info != null))
            {
                UserInfoDao dao = new UserInfoDao();
                using (Transaction tx = new Transaction())
                {
                    dao.Delete<UserInfo>(info);
                    tx.Commit();
                }
                info = null;
            }

            MembershipUserWrapper wrapper = new MembershipUserWrapper();
            wrapper.MembershipUser = user;
            wrapper.UserInfo = info;

            return wrapper;
        }