public IQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation> Get_OperationsList_List1DataSet_DatasourceQueryableImplementation(DatasourceRequest __request = null, bool shouldEvict = true)
        {
            __request = __request ?? new DatasourceRequest(0, int.MaxValue);
            var __items = new DSS4_ECompliance.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationOperation>().AsQueryable();

            return(__items.Where(@this => true));
        }
Beispiel #2
0
        public IQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationPermission> Get_ManageOperation_Button2DataSet_DatasourceQueryableImplementation(DatasourceRequest __request = null, bool shouldEvict = true)
        {
            __request = __request ?? new DatasourceRequest(0, int.MaxValue);
            var __items = new DSS4_ECompliance.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationPermission>().AsQueryable();

            return(__items);
        }
Beispiel #3
0
        /*<ControllerActionImplementation:Create:1/>*/
        public ActionResult ExecuteCreate()
        {
            ActionResult _result = null;

            _result = this.ExecuteAuthorizeAccess();
            if (@model.password?.Trim() != @model.repeatPassword?.Trim())
            {
                throw new Exception("Passwords do not match!");
            }
            if (@model.username?.Trim() == "")
            {
                throw new Exception("No username provided!");
            }
            zAppDev.DotNet.Framework.Identity.Model.ApplicationRole adminRole = new DSS4_ECompliance.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((r) => r.Name == "Administrator")?.FirstOrDefault();
            if ((adminRole == null))
            {
                throw new Exception("No Administrator role found in Database!");
            }
            zAppDev.DotNet.Framework.Identity.Model.ApplicationUser adminUser = new zAppDev.DotNet.Framework.Identity.Model.ApplicationUser();
            adminUser.UserName = (@model.username?.Trim() ?? "");
            adminUser?.AddRoles(adminRole);
            string possibleError = zAppDev.DotNet.Framework.Identity.IdentityHelper.CreateUser(adminUser, (@model.password?.Trim() ?? ""));

            if ((((possibleError == null || possibleError == "")) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, possibleError, MessageType.Error);
                return(null);
            }
            _result = GetRedirectInfo("SignInPage", "Load", new  RouteValueDictionary(new {  }));
            return(_result);
        }
Beispiel #4
0
        /*<ControllerActionImplementation:Save:1/>*/
        public ActionResult ExecuteSave()
        {
            ActionResult _result = null;

            zAppDev.DotNet.Framework.Identity.Model.ApplicationRole role = new DSS4_ECompliance.DAL.Repository().GetAsQueryable <zAppDev.DotNet.Framework.Identity.Model.ApplicationRole>((r) => r.Name == "Administrator")?.FirstOrDefault();
            if (role == null)
            {
                throw new Exception((BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_CUSTOM_NoAdminRoleFound").ToString()));
            }
            if ((@model.ApplicationUser?.IsInRole("Administrator") ?? false))
            {
                throw new Exception((BaseViewPage <string> .GetResourceValue("FirstAdminSetup", "RES_CUSTOM_AlreadyAdmin").ToString()));
            }
            @model.ApplicationUser?.AddRoles(role);
            new DSS4_ECompliance.DAL.Repository().Save <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(@model.ApplicationUser);
            _result = GetRedirectInfo("HomePage", "Render", new  RouteValueDictionary(new {  }));
            return(_result);
        }
        /*<ControllerActionImplementation:ResetPasswordRequest:1/>*/
        public ActionResult ExecuteResetPasswordRequest()
        {
            ActionResult _result = null;

            zAppDev.DotNet.Framework.Identity.Model.ApplicationUser user = new DSS4_ECompliance.DAL.Repository().GetById <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(@model.txtUsername);
            if (user == null)
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_NotFound").ToString(), MessageType.Error);
                return(null);
            }
            if (((user?.Email ?? "") == null || (user?.Email ?? "").Trim() == "") || ((((user?.Email ?? "") == null ? false : CSharpVerbalExpressions.VerbalExpressions.DefaultExpression.Add(CSharpVerbalExpressions.CommonRegex.Email).Test((user?.Email ?? "")))) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_NoMail").ToString(), MessageType.Error);
                return(null);
            }
            string key      = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetUserManager().GeneratePasswordResetTokenAsync(user.UserName).Result;
            string resetUrl = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                               System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                              "/ForgotPassword/ResetPassword" + "?username="******"")) + "&key=" + System.Web.HttpUtility.UrlEncode(System.Web.HttpUtility.UrlEncode(key));

            zAppDev.DotNet.Framework.Utilities.EMailMessage mail       = new zAppDev.DotNet.Framework.Utilities.EMailMessage();
            System.Collections.Generic.List <string>        recipients = new System.Collections.Generic.List <string>();
            recipients.Add((user?.Email ?? ""));
            mail.To         = recipients.ToList();
            mail.IsBodyHtml = true;
            mail.Subject    = BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_ResetPasswordLink").ToString() + " " + "DSS4_ECompliance";

            mail.Body = "<h3>" + BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_ClickToReset").ToString() + "</h3>" + "<a href='" + resetUrl + "'>" + BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_ResetPassword").ToString() + "</a>" + "<h3>" + BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_CopyPaste").ToString() + "</h3><p>" + resetUrl + "</p>";

            zAppDev.DotNet.Framework.Utilities.Email.SendMail(mail);
            string signInUrl = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                                System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                               "/SignInPage/Load";

            ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_MailSoon").ToString(), MessageType.Success, signInUrl);
            return(_result);
        }
        /*<ControllerActionImplementation:ResetPassword:1/>*/
        public ActionResult ExecuteResetPassword(string username, string key)
        {
            if (_parentController == null)
            {
                _parentController = new MasterPage.MasterPageController(new  DSS4_ECompliance.UI.ViewModels.MasterPage.MasterPageViewModel());
            }
            ((MasterPage.MasterPageController)_parentController).ExecuteRender();
            ActionResult _result = null;

            @model.Title = null;
            if (((username == null || username.Trim() == "")))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_InvalidLink").ToString(), MessageType.Error);
                return(null);
            }
            zAppDev.DotNet.Framework.Identity.Model.ApplicationUser user = new DSS4_ECompliance.DAL.Repository().GetById <zAppDev.DotNet.Framework.Identity.Model.ApplicationUser>(username);
            if (user == null)
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_NotFound").ToString(), MessageType.Error);
                return(null);
            }
            string newPassword = "******" + Guid.NewGuid().ToString().ToLower().Replace("-", "").Substring(0, 10);
            bool   success     = zAppDev.DotNet.Framework.Identity.IdentityHelper.GetUserManager().ResetPasswordAsync(user.UserName, key, newPassword).Result.Succeeded;

            if (((success) == false))
            {
                ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_InvalidLink").ToString(), MessageType.Error);
                return(null);
            }
            string signInUrl = (!string.IsNullOrEmpty(System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"]) ?
                                System.Configuration.ConfigurationManager.AppSettings["ServerExternalPath"] : zAppDev.DotNet.Framework.Utilities.Web.GetApplicationPathUri(false)) +
                               "/SignInPage/Load";

            ClientCommand(ClientCommands.SHOW_MESSAGE, BaseViewPage <string> .GetResourceValue("ForgotPassword", "RES_CUSTOM_YourNewPass").ToString() + " " + newPassword, MessageType.Success, signInUrl);
            return(_result);
        }