private static BitplateUser CreateDummyUser() { string checkDevelopMode = ConfigurationManager.AppSettings["DevelopMode"]; if (checkDevelopMode == "qweutyrqwe81238761238917263876123128376123") { BitplateUser user = new BitplateUser(); user.ID = new Guid("afbc2811-2487-4c01-83b2-b9479f82a99d"); user.Name = "Dummy"; user.Email = "*****@*****.**"; //user.CurrentSite = new LicenseSite(); ////user.SuperUserType = SuperUserTypeEnum.Developers; //string siteID = ConfigurationManager.AppSettings["SiteID"]; //if (SessionObject.CurrentSite != null) //{ // user.CurrentSite = new LicenseSite(); // user.CurrentSite.ID = SessionObject.CurrentSite.ID; //} user.Theme = "bitplate"; user.Language = "NL"; BitplateUserGroup group = new BitplateUserGroup(); group.Type = UserTypeEnum.Developers; user.UserGroups.Add(group); return(user); } else { return(null); } }
public BitplateUserGroup GetUserGroup(string id) { BitplateUserGroup userGroup = null; if (id == null || id == "") { userGroup = new BitplateUserGroup(); } else { userGroup = BaseObject.GetById <BitplateUserGroup>(new Guid(id)); } return(userGroup); }
private static BitplateUser CreateDummyUser() { string checkDevelopMode = ConfigurationManager.AppSettings["DevelopMode"]; if (checkDevelopMode == "qweutyrqwe81238761238917263876123128376123") { BitplateUser user = new BitplateUser(); user.ID = new Guid("afbc2811-2487-4c01-83b2-b9479f82a99d"); user.Name = "Dummy"; user.Email = "*****@*****.**"; user.CurrentSite = new LicenseSite(); //user.SuperUserType = SuperUserTypeEnum.Developers; string siteID = ConfigurationManager.AppSettings["SiteID"]; if (SessionObject.CurrentSite != null) { user.CurrentSite = new LicenseSite(); user.CurrentSite.ID = SessionObject.CurrentSite.ID; } user.Theme = "bitplate"; user.Language = "NL"; BitplateUserGroup group = new BitplateUserGroup(); //group.Site = new LicenseSite(); //group.Site.ID = SessionObject.CurrentSite.ID; group.SuperUserGroupType = SuperUserTypeEnum.Developers; Functionality permission = new Functionality(); permission.FunctionNumber = FunctionalityEnum.FileManager; group.UserGroupPermissions.Add(permission); user.UserGroups.Add(group); user.AllPermissions4CurrentSite = new List <int>(); foreach (FunctionalityEnum funcEnumValue in Enum.GetValues(typeof(FunctionalityEnum))) { user.AllPermissions4CurrentSite.Add((int)funcEnumValue); } return(user); } else { return(null); } }
private void CreateSystemUserGroupsIfNotExists(out BitplateUserGroup UserGroupAdmins, out BitplateUserGroup UserGroupEveryOne) { UserGroupAdmins = BaseObject.GetFirst <BitplateUserGroup>("FK_Site = '" + SessionObject.CurrentSite.ID + "' AND IsSystemValue = 1 AND Type=9"); if (UserGroupAdmins == null) { UserGroupAdmins = new BitplateUserGroup(); UserGroupAdmins.Type = UserTypeEnum.SiteAdmins; UserGroupAdmins.Name = "Admins"; UserGroupAdmins.IsSystemValue = true; UserGroupAdmins.Save(); } UserGroupEveryOne = BaseObject.GetFirst <BitplateUserGroup>("FK_Site = '" + SessionObject.CurrentSite.ID + "' AND IsSystemValue = 1 AND Type=0"); if (UserGroupEveryOne == null) { UserGroupEveryOne = new BitplateUserGroup(); UserGroupEveryOne.Type = UserTypeEnum.Custom; UserGroupEveryOne.Name = "Everyone"; UserGroupEveryOne.IsSystemValue = true; UserGroupEveryOne.Save(); } }
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); }
public void SaveUserGroup(BitplateUserGroup obj) { obj.Save(); }