Ejemplo n.º 1
0
        partial void OnCreated(object sender, BusinessRulesEventArgs <KstProxyUser> e)
        {
            var contextRequest = e.ContextRequest;


            var user = new secUser()
            {
                GuidUser = e.Item.GuidUser
            };

            e.ContextRequest.PreventInterceptors = true;
            var role = SFS.Core.Security.BR.secRolesBR.Instance.GetBy(p => p.GuidRole == e.Item.GuidRole, e.ContextRequest).FirstOrDefault();

            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 == user.GuidUser && p.GuidCompany == guidCompany && p.GuidModule == guidModule).FirstOrDefault();

            userCompanyRole             = new SFS.Core.Security.BusinessObjects.secUserCompany();
            userCompanyRole.GuidUser    = user.GuidUser;
            userCompanyRole.GuidRole    = role.GuidRole;
            userCompanyRole.GuidModule  = guidModule;
            userCompanyRole.GuidCompany = guidCompany.Value;

            userCompanyRole = SFS.Core.Security.BR.secUserCompaniesBR.Instance.Create(userCompanyRole, contextRequest);



            this.NotifyUserAsync(new secUser()
            {
                GuidUser = e.Item.GuidUser, Email = e.Item.Email, FirstName = e.Item.FirstName, LastName = e.Item.LastName
            }, role.RoleName, contextRequest);
        }
Ejemplo n.º 2
0
        partial void OnCreating(object sender, BusinessRulesEventArgs <KstProxyUser> e)
        {
            #region
            secUser sysUser = new secUser();
            sysUser.UserName    = e.Item.Email;
            sysUser.FirstName   = e.Item.FirstName;
            sysUser.LastName    = e.Item.LastName;
            e.Item.DisplayName  = e.Item.FirstName + " " + e.Item.LastName;
            sysUser.DisplayName = e.Item.DisplayName;
            #endregion
            if (e.Item.Password != null)
            {
                sysUser.Password = SFS.Core.Globals.Security.EncryptString(e.Item.Password);
            }
            sysUser.Email    = e.Item.Email;
            sysUser.Password = e.Item.Password;
            sysUser          = SFS.Core.Security.BR.secUsersBR.Instance.Create(sysUser, e.ContextRequest);

            e.Item.GuidUser = sysUser.GuidUser;
        }
Ejemplo n.º 3
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);
            }
        }
Ejemplo n.º 4
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);
            }
        }
Ejemplo n.º 5
0
 public void NotifyUserAsync(secUser user, ContextRequest contextRequest)
 {
     Task.Run(() => {
         this.NotifyUser(user, contextRequest);
     });
 }
Ejemplo n.º 6
0
 public void NotifyUserAsync(secUser user, string roleName, ContextRequest contextRequest)
 {
     Task.Run(() => {
         this.NotifyUser(user, roleName, contextRequest);
     });
 }