Exemple #1
0
            }                                     // for external login only

            public async Task UpdateAsync()
            {
                LoginConfigData config = await LoginConfigDataProvider.GetConfigAsync();

                RegisterModule regMod = (RegisterModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(RegisterModule));

                bool closeOnLogin;

                Manager.TryGetUrlArg <bool>("CloseOnLogin", out closeOnLogin, false);
                ForgotPasswordModule pswdMod = (ForgotPasswordModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(ForgotPasswordModule));

                ModuleAction pswdAction = await pswdMod.GetAction_ForgotPasswordAsync(config.ForgotPasswordUrl, CloseOnLogin : closeOnLogin);

                if (pswdAction != null)
                {
                    pswdAction.AddToOriginList = false;
                }
                Actions.New(pswdAction);
                ModuleAction registerAction = await regMod.GetAction_RegisterAsync(config.RegisterUrl, Force : true, CloseOnLogin : closeOnLogin);

                if (registerAction != null)
                {
                    registerAction.AddToOriginList = false;
                }
                Actions.New(registerAction);
            }
Exemple #2
0
            public async Task UpdateAsync()
            {
                LoginConfigData config = await LoginConfigDataProvider.GetConfigAsync();

                RegisterModule regMod = (RegisterModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(RegisterModule));

                LoginModule loginMod = (LoginModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(LoginModule));

                bool closeOnLogin;

                Manager.TryGetUrlArg <bool>("CloseOnLogin", out closeOnLogin, false);

                ModuleAction logAction = await loginMod.GetAction_LoginAsync(config.LoginUrl, Force : true, CloseOnLogin : closeOnLogin);

                if (logAction != null)
                {
                    logAction.AddToOriginList = false;
                }
                Actions.New(logAction);
                ModuleAction regAction = await regMod.GetAction_RegisterAsync(config.RegisterUrl, Force : true, CloseOnLogin : closeOnLogin);

                if (regAction != null)
                {
                    regAction.AddToOriginList = false;
                }
                Actions.New(regAction);
            }
Exemple #3
0
        private async Task <object> EvaluateObjectAsmTypeExpressionAsync(string objText, bool UniqueMod = false)
        {
            string[] s = objText.Split(new char[] { ',' });
            if (s.Length != 2)
            {
                throw TemplateError("Object {0} invalid (need assembly, type)", objText);
            }
            string assembly = s[0].Trim();

            if (string.IsNullOrWhiteSpace(assembly))
            {
                throw TemplateError("Assembly missing");
            }
            string type = s[1].Trim();

            if (string.IsNullOrWhiteSpace(type))
            {
                throw TemplateError("Type missing");
            }

            try {
                Assembly asm = Assemblies.Load(assembly);
                Type     tp  = asm.GetType(type);
                if (UniqueMod)
                {
                    return(await ModuleDefinition.CreateUniqueModuleAsync(tp));
                }
                else
                {
                    return(Activator.CreateInstance(tp));
                }
            } catch (Exception exc) {
                throw TemplateError("Can't create object {0}, {1}", assembly, type, ErrorHandling.FormatExceptionMessage(exc));
            }
        }
Exemple #4
0
        /// <summary>
        /// Called by the framework when the component needs to be rendered as HTML.
        /// </summary>
        /// <param name="model">The model being rendered by the component.</param>
        /// <returns>The component rendered as HTML.</returns>
        public async Task <string> RenderAsync(SerializableList <ModuleDefinition.ReferencedModule> model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            if (model == null)
            {
                model = new SerializableList <ModuleDefinition.ReferencedModule>();
            }

            bool header = PropData.GetAdditionalAttributeValue("Header", true);

            GridModel grid = new GridModel()
            {
                GridDef = GetGridModel(header)
            };

            grid.GridDef.DirectDataAsync = async(int skip, int take, List <DataProviderSortInfo> sorts, List <DataProviderFilterInfo> filters) => {
                List <AddOnManager.Module> allMods = Manager.AddOnManager.GetUniqueInvokedCssModules();

                List <Entry> mods = new List <Entry>();
                foreach (AddOnManager.Module allMod in allMods)
                {
                    if ((from m in model where m.ModuleGuid == allMod.ModuleGuid select m).FirstOrDefault() != null)
                    {
                        ModuleDefinition modDef = await ModuleDefinition.CreateUniqueModuleAsync(allMod.ModuleType);

                        if (modDef != null)
                        {
                            mods.Add(new Entry {
                                Name          = modDef.Name,
                                Description   = modDef.Description,
                                PermanentName = modDef.PermanentModuleName,
                            });
                        }
                    }
                }
                DataSourceResult data = new DataSourceResult {
                    Data  = mods.ToList <object>(),
                    Total = mods.Count,
                };
                return(data);
            };

            hb.Append($@"
<div class='yt_invokedmodules t_display'>
    {await HtmlHelper.ForDisplayAsAsync(Container, PropertyName, FieldName, grid, nameof(grid.GridDef), grid.GridDef, "Grid", HtmlAttributes: HtmlAttributes)}
</div>");

            return(hb.ToString());
        }
Exemple #5
0
        public async Task <string> RenderAsync(string model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            YTagBuilder tag = new YTagBuilder("span");

            FieldSetup(tag, FieldType.Anonymous);

            ModuleAction actionDisplay = null;
            ModuleAction actionLoginAs = null;

            using (UserDefinitionDataProvider userDefDP = new UserDefinitionDataProvider()) {
                UserDefinition user     = null;
                string         userName = "";
                if (!string.IsNullOrWhiteSpace(model))
                {
                    user = await userDefDP.GetItemByEmailAsync(model);

                    if (user == null)
                    {
                        userName = model;
                    }
                    else
                    {
                        userName = user.Email;
                        UsersDisplayModule modDisp = new UsersDisplayModule();
                        actionDisplay = modDisp.GetAction_Display(null, user.UserName);
                        LoginModule modLogin = (LoginModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(LoginModule));

                        actionLoginAs = await modLogin.GetAction_LoginAsAsync(user.UserId, user.UserName);
                    }
                }
                else
                {
                    userName = __ResStr("noEmail", "(not specified)");
                }
                tag.SetInnerText(userName);
            }
            hb.Append(tag.ToString(YTagRenderMode.Normal));
            if (actionDisplay != null)
            {
                hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            if (actionLoginAs != null)
            {
                hb.Append(await actionLoginAs.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            return(hb.ToString());
        }
Exemple #6
0
        public async Task <string> RenderAsync(int model)
        {
            HtmlBuilder hb = new HtmlBuilder();

            YTagBuilder tag = new YTagBuilder("span");

            tag.AddCssClass("yt_yetawf_identity_userid");
            tag.AddCssClass("t_display");
            FieldSetup(tag, FieldType.Anonymous);

            ModuleAction actionDisplay = null;
            ModuleAction actionLoginAs = null;

            using (UserDefinitionDataProvider dataProvider = new UserDefinitionDataProvider()) {
                UserDefinition user = await dataProvider.GetItemByUserIdAsync(model);

                string userName = "";
                if (user == null)
                {
                    if (model != 0)
                    {
                        userName = string.Format("({0})", model);
                    }
                }
                else
                {
                    userName = user.UserName;
                    Modules.UsersDisplayModule modDisp = new Modules.UsersDisplayModule();
                    actionDisplay = modDisp.GetAction_Display(null, userName);
                    Modules.LoginModule modLogin = (Modules.LoginModule) await ModuleDefinition.CreateUniqueModuleAsync(typeof(Modules.LoginModule));

                    actionLoginAs = await modLogin.GetAction_LoginAsAsync(model, userName);
                }
                tag.SetInnerText(userName);
            }

            hb.Append(tag.ToString(YTagRenderMode.Normal));
            if (actionDisplay != null)
            {
                hb.Append(await actionDisplay.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }
            if (actionLoginAs != null)
            {
                hb.Append(await actionLoginAs.RenderAsync(ModuleAction.RenderModeEnum.IconsOnly));
            }

            return(hb.ToString());
        }
Exemple #7
0
        public async Task SendNewUserCreatedAsync(UserDefinition user)
        {
            // get the registration module for some defaults
            RegisterModule regMod = (RegisterModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(RegisterModule));

            ModuleAction reject = await regMod.GetAction_RejectAsync(user.UserName);

            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                User      = user,
                RejectUrl = reject.GetCompleteUrl(),
            };
            string subject = this.__ResStr("notifyNewUserSubject", "New account for user {0} - site  {1}", user.UserName, Manager.CurrentSite.SiteDomain);
            await sendEmail.PrepareEmailMessageAsync(null, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "New Account Created.txt"), Parameters : parms);

            await sendEmail.SendAsync(false);

            SendingEmailAddress = await sendEmail.GetSendingEmailAddressAsync();
        }
Exemple #8
0
        public async Task SendPasswordResetEmailAsync(UserDefinition user, string ccEmail = null)
        {
            ResetPasswordModule resetMod = (ResetPasswordModule)await ModuleDefinition.CreateUniqueModuleAsync(typeof(ResetPasswordModule));

            ModuleAction reset = resetMod.GetAction_ResetPassword(null, user.UserId, user.ResetKey.ToString());

            SendEmail sendEmail = new SendEmail();
            object    parms     = new {
                User       = user,
                ResetUrl   = reset.GetCompleteUrl(),
                ResetKey   = user.ResetKey.ToString(),
                ValidUntil = Formatting.FormatDateTime(user.ResetValidUntil),
            };
            string subject = this.__ResStr("resetSubject", "Password Reset for {0}", Manager.CurrentSite.SiteDomain);
            await sendEmail.PrepareEmailMessageAsync(user.Email, subject, await sendEmail.GetEmailFileAsync(Package.GetCurrentPackage(this), "Password Reset.txt"), Parameters : parms);

            if (!string.IsNullOrWhiteSpace(ccEmail))
            {
                sendEmail.AddBcc(ccEmail);
            }
            await sendEmail.SendAsync(true);

            SendingEmailAddress = await sendEmail.GetSendingEmailAddressAsync();
        }