示例#1
0
        public Result Login(LoginDetails loginDetails)
        {
            Result ret = new Result();

            try
            {
                MEIdentity.Login(loginDetails);
                ret.Success = true;
                if (MEWebSecurity.CurrentIdentity().FirstTimeLogin)
                {
                    ret.Data = "ChangePassword.aspx";
                }
            }
            catch
            {
                ret.ErrorText = "";
                ret.Success   = false;
            }

            return(ret);
        }
示例#2
0
        /// <summary>
        /// Setup the login status control
        /// </summary>
        protected override void Setup()
        {
            base.Setup();

            HTMLDiv <object> container = Helpers.Div();

            container.Style.Display = Display.inlineblock;
            container.Style.MarginLeft("20px");

            string loginUrl   = VirtualPathUtility.ToAbsolute(FormsAuthentication.LoginUrl);
            string defaultUrl = VirtualPathUtility.ToAbsolute(FormsAuthentication.DefaultUrl);

            // Logged in
            if (Singular.Security.Security.HasAuthenticatedUser)
            {
                MEIdentity identity = MEWebSecurity.CurrentIdentity();

                var loginStatus = container.Helpers.DivC("login-status");
                {
                    loginStatus.Attributes["data-ContextMenu"] = "cmSecurity";

                    // User label
                    var userLabel = loginStatus.Helpers.HTMLTag("span", "Hello " + identity.FirstName);
                    {
                        userLabel.Style.Display = Display.inlineblock;
                    }

                    // Icon
                    loginStatus.Helpers.Image().Glyph = Singular.Web.FontAwesomeIcon.user;

                    // Context menu
                    var contextMenu = loginStatus.Helpers.DivC("context-menu-ls");
                    {
                        contextMenu.Attributes["id"] = "cmSecurity";
                        contextMenu.Style.TextAlign  = Singular.Web.TextAlign.right;

                        var contextMenuMain = contextMenu.Helpers.DivC("CM-Main");
                        {
                            var contextMenuMainHeader = contextMenuMain.Helpers.Div();
                            {
                                contextMenuMainHeader.AddClass("CM-Header");
                                contextMenuMainHeader.Helpers.Div().Helpers.HTML(identity.UserNameReadable);
                                contextMenuMainHeader.Helpers.Div().Helpers.HTML(identity.EmailAddress);
                            }

                            var contextMenuBody = contextMenuMain.Helpers.Div();
                            {
                                contextMenuBody.AddClass("Selectable");

                                // Uncomment if you have an edit profile page
                                var contextMenuEditProfile = contextMenuBody.Helpers.Div();
                                {
                                    contextMenuEditProfile.Helpers.LinkFor(null, null, VirtualPathUtility.ToAbsolute("~/Users/UserProfile.aspx?UserID=" + HttpUtility.UrlEncode(Singular.Encryption.EncryptString(identity.UserID.ToString()))), "Edit Profile");
                                }

                                // Change password
                                var contextMenuChangePassword = contextMenuBody.Helpers.Div();
                                {
                                    contextMenuChangePassword.Helpers.LinkFor(null, null, VirtualPathUtility.ToAbsolute("~/Account/ChangePassword.aspx"), "Change Password");
                                }

                                // Logout
                                var contextMenuLogout = contextMenuBody.Helpers.Div();
                                {
                                    contextMenuLogout.Helpers.LinkFor(null, null, defaultUrl + "?SCmd=Logout", "Logout");
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                // Logged out
                var loggedOutDiv = container.Helpers.Div();
                {
                    loggedOutDiv.Style.FontSize = "14px";
                    loggedOutDiv.Helpers.LinkFor(null, null, loginUrl, "Login").Style["text-decoration"] = "none";
                    loggedOutDiv.Helpers.Image().Glyph = FontAwesomeIcon.user;
                }
            }
        }
示例#3
0
        /// <summary>
        /// Setup the login status control
        /// </summary>
        protected override void Setup()
        {
            base.Setup();

            HTMLTag <object> listItem = Helpers.HTMLTag("li");

            listItem.AddClass("dropdown");

            string loginUrl   = VirtualPathUtility.ToAbsolute(FormsAuthentication.LoginUrl);
            string defaultUrl = VirtualPathUtility.ToAbsolute(FormsAuthentication.DefaultUrl);

            // Logged in
            if (Singular.Security.Security.HasAuthenticatedUser)
            {
                MEIdentity identity = MEWebSecurity.CurrentIdentity();

                var aTagUserName = listItem.Helpers.HTMLTag("a");
                aTagUserName.AddClass("dropdown-toggle count-info");
                aTagUserName.Attributes["data-toggle"] = "dropdown";
                {
                    aTagUserName.Helpers.HTML(MELib.CommonData.Lists.ROUserList.GetItem(identity.UserID).FullName);
                    var iTagUserName = aTagUserName.Helpers.HTMLTag("i");
                    iTagUserName.AddClass("fa fa-angle-down fa-lg");
                }

                var ulTagDropDown = listItem.Helpers.HTMLTag("ul");
                ulTagDropDown.AddClass("dropdown-menu animated fadeInRight");
                {
                    var liTagEditProfile = ulTagDropDown.Helpers.HTMLTag("li");
                    {
                        var aTagEditProfile = liTagEditProfile.Helpers.HTMLTag("a");
                        aTagEditProfile.Attributes["href"] = VirtualPathUtility.ToAbsolute("~/Users/UserProfile.aspx?UserID=" + HttpUtility.UrlEncode(Singular.Encryption.EncryptString(identity.UserID.ToString())));
                        {
                            var iTagEditProfile = aTagEditProfile.Helpers.HTMLTag("i");
                            iTagEditProfile.AddClass("fa fa-user pad_5_right");
                        }
                        aTagEditProfile.Helpers.HTML("Edit Profile");
                    }

                    var liDivider = ulTagDropDown.Helpers.HTMLTag("li");
                    liDivider.AddClass("divider");

                    var liTagChangePassword = ulTagDropDown.Helpers.HTMLTag("li");
                    {
                        var aTagChangePassword = liTagChangePassword.Helpers.HTMLTag("a");
                        aTagChangePassword.Attributes["href"] = VirtualPathUtility.ToAbsolute("~/Account/ChangePassword.aspx");
                        {
                            var iTagChangePassword = aTagChangePassword.Helpers.HTMLTag("i");
                            iTagChangePassword.AddClass("fa fa-lock pad_5_right");
                        }
                        aTagChangePassword.Helpers.HTML("Change Password");
                    }

                    var liDivider1 = ulTagDropDown.Helpers.HTMLTag("li");
                    liDivider1.AddClass("divider");

                    var liTagLogout = ulTagDropDown.Helpers.HTMLTag("li");
                    {
                        var aTagLogout = liTagLogout.Helpers.HTMLTag("a");
                        aTagLogout.Attributes["href"] = defaultUrl + "?SCmd=Logout";
                        {
                            var iTagLogout = aTagLogout.Helpers.HTMLTag("i");
                            iTagLogout.AddClass("fa fa-sign-out pad_5_right");
                        }
                        aTagLogout.Helpers.HTML("Log Out");
                    }
                }
            }
            else
            {
                // Logged out
                var aLogin = listItem.Helpers.HTMLTag("a");
                {
                    var iTagUserName = aLogin.Helpers.HTMLTag("i");
                    iTagUserName.AddClass("fa fa-sign-in fa-lg");
                    aLogin.Attributes["href"] = loginUrl;
                    aLogin.Helpers.HTML("Log In");
                }
            }
        }