Example #1
0
        private void Updating(KstProxyUser user, ContextRequest contextRequest)
        {
            Guid?guidUser = user.GuidUser;
            var  sysUser  = SFS.Core.Security.BR.secUsersBR.Instance.GetBy(p => p.GuidUser == guidUser, contextRequest).FirstOrDefault();

            if (sysUser != null)
            {
                List <string> props = new List <string>();
                sysUser.UserName = user.Username;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.Username))
                {
                    props.Add("UserName");
                }
                sysUser.FirstName = user.FirstName;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.FirstName))
                {
                    props.Add("FirstName");
                }
                sysUser.LastName = user.LastName;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.LastName))
                {
                    props.Add("LastName");
                }

                if (!string.IsNullOrEmpty(user.Password))
                {
                    if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.Password))
                    {
                        props.Add("Password");
                    }
                    sysUser.Password = SFS.Core.Globals.Security.EncryptString(user.Password);
                    user.Password    = null;
                }
                sysUser.Email = user.Email;
                if (contextRequest.CustomQuery.SpecificProperties.Contains(KstProxyUser.PropertyNames.Email))
                {
                    props.Add("Email");
                }
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(sysUser, contextRequest.CopySafe(), props.ToArray());
            }



            if (user.GuidRole != null)
            {
                Guid?guidCompany     = contextRequest.Company.GuidCompany;
                var  module          = SFS.Core.Cache.Caching.SystemObjects.GetModuleByKey("KSTime");
                Guid?guidModule      = module.GuidModule;
                var  userCompanyRole = SFS.Core.Security.BR.secUserCompaniesBR.Instance.GetBy(p => p.GuidUser == guidUser && p.GuidCompany == guidCompany && p.GuidModule == guidModule).FirstOrDefault();

                if (userCompanyRole != null)
                {
                    userCompanyRole.GuidRole = user.GuidRole;
                    SFS.Core.Security.BR.secUserCompaniesBR.Instance.UpdateAgile(userCompanyRole, contextRequest.CopySafe(), "GuidRole");
                }
                else
                {
                    userCompanyRole             = new SFS.Core.Security.BusinessObjects.secUserCompany();
                    userCompanyRole.GuidUser    = guidUser;
                    userCompanyRole.GuidRole    = user.GuidRole;
                    userCompanyRole.GuidModule  = guidModule;
                    userCompanyRole.GuidCompany = guidCompany.Value;

                    userCompanyRole = SFS.Core.Security.BR.secUserCompaniesBR.Instance.Create(userCompanyRole, contextRequest);
                }
            }
        }
Example #2
0
        public void NotifyUser(secUser user, ContextRequest contextRequest)
        {
            var template = KstEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "welcome", contextRequest.CopySafe()).FirstOrDefault();

            //var layoutTemplate = ubiEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "email-template", contextRequest.CopySafe()).FirstOrDefault();

            if (template != null && template.Content != null)
            {
                string content = template.Content;

                string code = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                user.EmailCodeVerirication = code;
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(user, contextRequest, secUser.PropertyNames.EmailCodeVerirication);
                //content = content.Replace("{{NOMBRE-COMPLETO}}", user.FirstName + " " + user.LastName);

                content = content.Replace("{{URL-LINK}}", $"{contextRequest.CurrentContext.ApplicationHome}/App/#/activate-account/email/{user.Email}/code/{user.EmailCodeVerirication}");
                content = content.Replace("{{URL}}", $"{contextRequest.CurrentContext.ApplicationHome}/App/#/activate-account/email/{user.Email}/code/{user.EmailCodeVerirication}");
                content = content.Replace("{{EMAIL}}", user.Email);


                SFS.Core.Net.Mail.SendMailAsync(user.Email, "Bienvenid@ a TodoSí", content, contextRequest);
            }
        }
Example #3
0
        public void NotifyUser(secUser user, string roleName, ContextRequest contextRequest)
        {
            var template = KstEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "user-added", contextRequest.CopySafe()).FirstOrDefault();

            //var layoutTemplate = ubiEmailTemplatesBR.Instance.GetBy(p => p.TitleKey == "email-template", contextRequest.CopySafe()).FirstOrDefault();

            if (template != null && template.Content != null)
            {
                string content = template.Content;

                string code = Guid.NewGuid().ToString().Replace("-", "").Substring(0, 10);
                user.EmailCodeVerirication = code;
                SFS.Core.Security.BR.secUsersBR.Instance.UpdateAgile(user, contextRequest, secUser.PropertyNames.EmailCodeVerirication);

                content = content.Replace("{APP-NAME}", contextRequest.Module.Name);
                content = content.Replace("{FROM-USER-NAME}", contextRequest.User.FirstName);
                content = content.Replace("{ROLE-NAME}", roleName);
                content = content.Replace("{URL-LINK}", $"{contextRequest.CurrentContext.ApplicationHome}/App/#/set-password/email/{user.Email}/code/{user.EmailCodeVerirication}");
                var module = SFS.Core.Cache.Caching.SystemObjects.GetModuleByKey("KSTime");

                SFS.Core.Net.Mail.SendMailAsync(user.Email, "Bienvenido a " + module.Name, content, contextRequest);
            }
        }