public LicensedEnvironment[] GetSites(string sort, string searchString)
        {
            UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
            BitplateUser copyUser = new BitplateUser();

            copyUser.Email    = SessionObject.CurrentBitplateUser.Email;
            copyUser.Password = SessionObject.CurrentBitplateUser.Password;
            LicensedEnvironment[] returnValue = client.GetSiteUrls(copyUser);
            client.Close();
            return(returnValue);
        }
        public string ChangeSite(string id, string url)
        {
            //1 melden bij metaserver dat je gaat wisselen van site onder dezelfde gebruiker
            // meta server stuurt een key terug waarmee je ingelogd blijft
            //key meegeven in url van site waarnaar je gaat wisselen
            //2 wisselen sit
            //bij nieuwe site wordt key weer opgestuurd aan metaserver
            //klopt deze sleutel dan zuto inloggen bij de nieuwe site
            UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
            BitplateUser copyUser = new BitplateUser();

            copyUser.Email    = SessionObject.CurrentBitplateUser.Email;
            copyUser.Password = SessionObject.CurrentBitplateUser.Password;
            string loginkey = client.GenerateTempLoginKey(url, copyUser);

            client.Close();

            return(url + "/_bitplate/Login.aspx?loginkey=" + loginkey);



            //if (SessionObject.CurrentBitplateUser.CurrentSite == null)
            //{
            //    SessionObject.CurrentBitplateUser.CurrentSite = new LicenseSite();
            //}
            //SessionObject.CurrentBitplateUser.CurrentSite.ID = new Guid(id);
            //SessionObject.CurrentBitplateUser.StoreValues4CurrentSite(new Guid(id));
            //CmsSite site = BaseObject.GetById<CmsSite>(new Guid(id));
            //string serverName = Environment.MachineName;
            //BitSite.BitAutorisationService.AutorisationClient client = BitAutorisationServiceHelper.GetClient();
            //SessionObject.CurrentBitplateUser = client.ChangeSite(SessionObject.CurrentBitplateUser, new Guid(id));



            //if (site == null)
            //{
            //    SessionObject.CurrentSite = new CmsSite();
            //}
            //else
            //{
            //    //site.Port = HttpContext.Current.Request.Url.Port;
            //    //zet working environment in site
            //    string where = String.Format("FK_Site='{0}' AND SiteEnvironmentType={1}", site.ID, (int)SiteEnvironmentTypeEnum.Editable);
            //    CmsSiteEnvironment environment = BaseObject.GetFirst<CmsSiteEnvironment>(where);
            //    site.CurrentWorkingEnvironment = environment;
            //    //zet sessie
            //    SessionObject.CurrentSite = site;
            //    License l = client.LoadLicense(site.LicenceCode, serverName, site.DomainName);
            //    SessionObject.CurrentLicense = client.LoadLicense(site.LicenceCode, serverName, site.DomainName);
            //    site.IsValidLicense = (SessionObject.CurrentLicense != null);

            //}
        }
 public void SaveCurrentUser(BitplateUser obj)
 {
     obj.Save();
     if (obj.IsMultiSiteUser)
     {
         //userGroups & permissions hoeven niet opgeslagen bij multisite users
         obj.UserGroups.Clear();
         obj.Permissions = null;
         string domainName = getDomainName();
         UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
         client.SetUserData(obj, domainName);
         //weer laden om permissions & usergroups weer op te halen, usergroups eerst null maken
         obj.UserGroups = null;
         obj.Load();
     }
     SessionObject.CurrentBitplateUser = obj;
 }
        public bool SendNewPassword(string email)
        {
            bool         returnValue = false;
            BitplateUser user        = BaseObject.GetFirst <BitplateUser>("Email ='" + email + "'");

            if (user != null)
            {
                returnValue = user.SendNewPasswordEmail();
                if (user.IsMultiSiteUser)
                {
                    string domainName = getDomainName();
                    UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                    client.SetUserData(user, domainName);
                }
            }
            return(returnValue);
        }
        public bool SendNewPassword(string email)
        {
            bool         returnValue = false;
            BitplateUser user        = BaseObject.GetFirst <BitplateUser>("Email ='" + email + "'");
            //voor als je aankomt vanuit login.aspx --> nieuw ww aanvragen --> dan is er nog geen lic gezet
            LicenseFile lic = SessionObject.CurrentLicense;

            if (user != null)
            {
                returnValue = user.SendNewPasswordEmail();
                if (user.IsMultiSiteUser)
                {
                    string domainName = getDomainName();
                    UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                    client.SetUserData(user, domainName);
                }
            }
            return(returnValue);
        }
        public void SaveUser(BitplateUser obj)
        {
            //Quick password fix, kan vast mooier.
            if (!obj.IsNew)
            {
                BitplateUser currentUserObject = BaseObject.GetById <BitplateUser>(obj.ID);
                obj.Password = currentUserObject.Password;
            }

            obj.Save();
            if (obj.IsMultiSiteUser)
            {
                //userGroups & permissions hoeven niet opgeslagen bij multisite users
                obj.UserGroups.Clear();
                obj.Permissions = null;
                string domainName = getDomainName();
                UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                client.SetUserData(obj, domainName);
            }
        }
Exemple #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //als gebruiker met meerdere site heeft gewisseld naar een andere site dan krijgt die een tempkey mee vanuit de metaserver.
            //deze temp key checken in metaserver, bestaat die, dan autom. inloggen met deze gebruiker
            if (Request.QueryString["loginkey"] != null)
            {
                UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                MultiSiteUser tempUser = client.CheckTempLoginKey(Request.QueryString["loginkey"]);
                using (AuthService authService = new AuthService())
                {
                    authService.Login(tempUser.Email, null, tempUser.Theme, tempUser.Language, false, tempUser.Password);
                }
            }

            if (SessionObject.CurrentBitplateUser != null)
            {
                Session.Clear();
                Session.Abandon();
            }
            else
            {
                this.ShowLoginPage();
            }
        }
 public NewsItem[] GetNewsItems()
 {
     UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
     return(client.GetNewsItems());
 }
        public bool Login(string email, string password, string theme, string language, bool saveData, string md5Hash)
        {
            BitplateUserGroup userGroupAdmins;
            BitplateUserGroup userGroupEveryOne;

            CreateSystemUserGroupsIfNotExists(out userGroupAdmins, out userGroupEveryOne);

            SessionObject.CurrentSiteUser = null;
            bool returnValue = false;
            Guid SiteId;

            Guid.TryParse(ConfigurationManager.AppSettings["SiteID"], out SiteId);
            if (md5Hash == null)
            {
                md5Hash = CalculateMD5Hash(password);
            }
            BitplateUser user = BaseObject.GetFirst <BitplateUser>("Email ='" + email + "' AND Password = '******' AND Active = 1");

            if (user != null)
            {
                returnValue = true;
                SessionObject.CurrentBitplateUser = user;
                user.Theme = "bitplate";

                if (saveData)
                {
                    saveUserDataCookie(email, md5Hash); //OPSLAAN GEBRUIKERSGEGEVENS WERKT NOG NIET GOED.
                }
                else
                {
                    RemoveUserDataCookie();
                }
                if (user.IsMultiSiteUser)
                {
                    //gegevens syncen
                    //haal data op van meta server
                    string domainName = getDomainName();
                    UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                    MultiSiteUser multiSiteUser = null;
                    if (client != null)
                    {
                        multiSiteUser = client.Login(domainName, email, md5Hash);
                    }
                    //opslaan
                    if (multiSiteUser != null)
                    {
                        BitplateUser localUser = multiSiteUser.ToBitPlateUser(user.Email);
                        if (localUser.ModifiedDate > user.ModifiedDate)
                        {
                            localUser.UserGroups  = user.UserGroups;
                            localUser.Permissions = user.Permissions;
                            localUser.Save();
                            user = localUser;
                        }

                        if (multiSiteUser.IsAdmin)
                        {
                            if (!user.IsUserMemberOf(userGroupAdmins.Name))
                            {
                                user.UserGroups.Add(userGroupAdmins);
                                user.Save();
                            }
                        }
                        else
                        {
                            if (user.IsUserMemberOf(userGroupAdmins.Name))
                            {
                                BitplateUserGroup userGroup = BaseObject.GetFirst <BitplateUserGroup>("FK_Site = '" + SessionObject.CurrentSite.ID + "' AND Type=9");
                                user.UserGroups.Remove(userGroupAdmins);
                                user.Save();
                            }
                        }
                        //Gebruiker toevoegen aan systeem usergroup everyone.
                        if (!user.IsUserMemberOf(userGroupEveryOne.Name))
                        {
                            user.UserGroups.Add(userGroupEveryOne);
                            user.Save();
                        }
                        returnValue = true;
                        SessionObject.CurrentBitplateUser = user;
                    }
                    else if (multiSiteUser == null && client != null)
                    {
                        //Delete user als dit een multisiteuser is welke niet meer voorkomt in de licentie server.
                        user.Delete();
                        returnValue = false;
                    }
                    else
                    {
                        returnValue = true;
                        SessionObject.CurrentBitplateUser = user;
                    }
                }
            }
            else
            {
                //probeer in te loggen bij metaserver
                string domainName = getDomainName();
                UserServiceReference.UserServiceClient client = BitMetaServerServicesHelper.GetUserServiceClient();
                MultiSiteUser multiSiteUser = client.Login(domainName, email, md5Hash);

                if (multiSiteUser != null)
                {
                    //nieuwe user aanmaken en opslaan
                    BitplateUser localUser = multiSiteUser.ToBitPlateUser(email);
                    //usergroup toevoegen
                    if (multiSiteUser.IsAdmin)
                    {
                        localUser.UserGroups.Add(userGroupAdmins);
                    }
                    //Gebruiker toevoegen aan systeem usergroup everyone.
                    localUser.UserGroups.Add(userGroupEveryOne);
                    localUser.Save();
                    SessionObject.CurrentBitplateUser = localUser;

                    returnValue = true;
                }
            }

            return(returnValue);
        }