Пример #1
0
        private static bool VerifyHostUser(Dictionary <string, string> accountInfo, out string errorMsg)
        {
            var result = true;

            errorMsg = string.Empty;

            UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE;
            UserInfo        hostUser    = UserController.ValidateUser(-1, accountInfo["username"], accountInfo["password"], "DNN", "", "", AuthenticationLoginBase.GetIPAddress(), ref loginStatus);

            if (loginStatus == UserLoginStatus.LOGIN_FAILURE || !hostUser.IsSuperUser)
            {
                result   = false;
                errorMsg = LocalizeStringStatic("InvalidCredentials");
            }
            else
            {
                IsAuthenticated = true;
            }
            return(result);
        }
Пример #2
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// Runs when the Wizard's Next button is clicked
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]	02/20/2007	Created
        /// </history>
        /// -----------------------------------------------------------------------------
        protected void wizInstall_NextButtonClick(object sender, WizardNavigationEventArgs e)
        {
            switch (e.CurrentStepIndex)
            {
            case 0:
                //validate user
                var loginStatus = UserLoginStatus.LOGIN_FAILURE;
                var hostUser    = UserController.ValidateUser(-1, userNameTextBox.Text, passwordTextBox.Text, "DNN", "", "", AuthenticationLoginBase.GetIPAddress(), ref loginStatus);

                if (loginStatus != UserLoginStatus.LOGIN_FAILURE && hostUser.IsSuperUser)
                {
                    Response.Redirect("~/Install/Install.aspx?mode=upgrade");
                }
                else
                {
                    Response.Redirect("~/Install/UpgradeWizard.aspx");
                }
                break;
            }
        }
Пример #3
0
        private void BindLogin()
        {
            List <AuthenticationInfo> authSystems         = AuthenticationController.GetEnabledAuthenticationServices();
            AuthenticationLoginBase   defaultLoginControl = null;

            foreach (AuthenticationInfo authSystem in authSystems)
            {
                try
                {
                    //Figure out if known Auth types are enabled (so we can improve perf and stop loading the control)
                    bool enabled = true;
                    if (authSystem.AuthenticationType == "Facebook" || authSystem.AuthenticationType == "Google" ||
                        authSystem.AuthenticationType == "Live" || authSystem.AuthenticationType == "Twitter")
                    {
                        enabled = PortalController.GetPortalSettingAsBoolean(authSystem.AuthenticationType + "_Enabled", PortalId, false);
                    }

                    if (enabled)
                    {
                        var authLoginControl = (AuthenticationLoginBase)LoadControl("~/" + authSystem.LoginControlSrc);
                        BindLoginControl(authLoginControl, authSystem);
                        if (authSystem.AuthenticationType == "DNN")
                        {
                            defaultLoginControl = authLoginControl;
                        }

                        //Check if AuthSystem is Enabled
                        if (authLoginControl.Enabled)
                        {
                            var oAuthLoginControl = authLoginControl as OAuthLoginBase;
                            if (oAuthLoginControl != null)
                            {
                                //Add Login Control to List
                                _oAuthControls.Add(oAuthLoginControl);
                            }
                            else
                            {
                                //Add Login Control to List
                                _loginControls.Add(authLoginControl);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Exceptions.LogException(ex);
                }
            }
            int authCount = _loginControls.Count;

            switch (authCount)
            {
            case 0:
                //No enabled controls - inject default dnn control
                if (defaultLoginControl == null)
                {
                    //No controls enabled for portal, and default DNN control is not enabled by host, so load system default (DNN)
                    AuthenticationInfo authSystem = AuthenticationController.GetAuthenticationServiceByType("DNN");
                    var authLoginControl          = (AuthenticationLoginBase)LoadControl("~/" + authSystem.LoginControlSrc);
                    BindLoginControl(authLoginControl, authSystem);
                    DisplayLoginControl(authLoginControl, false, false);
                }
                else
                {
                    //Portal has no login controls enabled so load default DNN control
                    DisplayLoginControl(defaultLoginControl, false, false);
                }
                break;

            case 1:
                //We don't want the control to render with tabbed interface
                DisplayLoginControl(_loginControls[0], false, false);
                break;

            default:
                foreach (AuthenticationLoginBase authLoginControl in _loginControls)
                {
                    DisplayTabbedLoginControl(authLoginControl, tsLogin.Tabs);
                }

                break;
            }
            BindOAuthControls();
        }
Пример #4
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// ValidateUser runs when the user has been authorized by the data store.  It validates for
        /// things such as an expiring password, valid profile, or missing DNN User Association
        /// </summary>
        /// <param name="objUser">The logged in User</param>
        /// <param name="ignoreExpiring">Ignore the situation where the password is expiring (but not yet expired)</param>
        /// -----------------------------------------------------------------------------
        private void ValidateUser(UserInfo objUser, bool ignoreExpiring)
        {
            UserValidStatus validStatus = UserValidStatus.VALID;
            string          strMessage  = Null.NullString;
            DateTime        expiryDate  = Null.NullDate;

            validStatus = UserController.ValidateUser(objUser, PortalId, ignoreExpiring);

            if (PasswordConfig.PasswordExpiry > 0)
            {
                expiryDate = objUser.Membership.LastPasswordChangeDate.AddDays(PasswordConfig.PasswordExpiry);
            }
            UserId = objUser.UserID;

            //Check if the User has valid Password/Profile
            switch (validStatus)
            {
            case UserValidStatus.VALID:
                //Set the Page Culture(Language) based on the Users Preferred Locale
                if ((objUser.Profile != null) && (objUser.Profile.PreferredLocale != null))
                {
                    Localization.SetLanguage(objUser.Profile.PreferredLocale);
                }
                else
                {
                    Localization.SetLanguage(PortalSettings.DefaultLanguage);
                }

                //Set the Authentication Type used
                AuthenticationController.SetAuthenticationType(AuthenticationType);

                //Complete Login
                UserController.UserLogin(PortalId, objUser, PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), RememberMe);

                //redirect browser
                var redirectUrl = RedirectURL;

                //Clear the cookie
                HttpContext.Current.Response.Cookies.Set(new HttpCookie("returnurl", "")
                {
                    Expires = DateTime.Now.AddDays(-1)
                });

                Response.Redirect(redirectUrl, true);
                break;

            case UserValidStatus.PASSWORDEXPIRED:
                strMessage = string.Format(Localization.GetString("PasswordExpired", LocalResourceFile), expiryDate.ToLongDateString());
                AddLocalizedModuleMessage(strMessage, ModuleMessage.ModuleMessageType.YellowWarning, true);
                PageNo             = 2;
                pnlProceed.Visible = false;
                break;

            case UserValidStatus.PASSWORDEXPIRING:
                strMessage = string.Format(Localization.GetString("PasswordExpiring", LocalResourceFile), expiryDate.ToLongDateString());
                AddLocalizedModuleMessage(strMessage, ModuleMessage.ModuleMessageType.YellowWarning, true);
                PageNo             = 2;
                pnlProceed.Visible = true;
                break;

            case UserValidStatus.UPDATEPASSWORD:
                AddModuleMessage("PasswordUpdate", ModuleMessage.ModuleMessageType.YellowWarning, true);
                PageNo             = 2;
                pnlProceed.Visible = false;
                break;

            case UserValidStatus.UPDATEPROFILE:
                //When the user need update its profile to complete login, we need clear the login status because if the logrin is from
                //3rd party login provider, it may call UserController.UserLogin because they doesn't check this situation.
                new PortalSecurity().SignOut();
                //Admin has forced profile update
                AddModuleMessage("ProfileUpdate", ModuleMessage.ModuleMessageType.YellowWarning, true);
                PageNo = 3;
                break;
            }
            ShowPanel();
        }
Пример #5
0
        protected void CtrlItemCommand(object source, RepeaterCommandEventArgs e)
        {
            var cArg          = e.CommandArgument.ToString();
            var param         = new string[3];
            var redirecttabid = "";
            var emailtemplate = "";

            switch (e.CommandName.ToLower())
            {
            case "saveprofile":
                _profileData.UpdateProfile(rpInp, DebugMode);

                emailtemplate = ModSettings.Get("emailtemplate");
                if (emailtemplate != "")
                {
                    NBrightBuyUtils.SendEmailToManager(emailtemplate, _profileData.GetProfile(), "profileupdated_emailsubject.Text");
                }

                param[0] = "msg=" + NotifyRef + "_" + NotifyCode.ok;
                NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef, NotifyCode.ok);
                Response.Redirect(Globals.NavigateURL(TabId, "", param), true);
                break;

            case "register":

                var notifyCode = NotifyCode.fail;
                var failreason = "";

                var cap = (DotNetNuke.UI.WebControls.CaptchaControl)rpInp.Controls[0].FindControl("captcha");;
                if (cap == null || cap.IsValid)
                {
                    //create a new user and login
                    if (!this.UserInfo.IsInRole("Registered Users"))
                    {
                        // Create and hydrate User
                        var objUser = new UserInfo();
                        objUser.Profile.InitialiseProfile(this.PortalId, true);
                        objUser.PortalID                = PortalId;
                        objUser.DisplayName             = GenXmlFunctions.GetField(rpInp, "DisplayName");
                        objUser.Email                   = GenXmlFunctions.GetField(rpInp, "Email");
                        objUser.FirstName               = GenXmlFunctions.GetField(rpInp, "FirstName");
                        objUser.LastName                = GenXmlFunctions.GetField(rpInp, "LastName");
                        objUser.Username                = GenXmlFunctions.GetField(rpInp, "Username");
                        objUser.Profile.PreferredLocale = Utils.GetCurrentCulture();

                        if (objUser.Username == "")
                        {
                            objUser.Username = GenXmlFunctions.GetField(rpInp, "Email");
                        }
                        objUser.Membership.CreatedDate = System.DateTime.Now;
                        var passwd = GenXmlFunctions.GetField(rpInp, "Password");
                        if (passwd == "")
                        {
                            objUser.Membership.UpdatePassword = true;
                            passwd = UserController.GeneratePassword(9);
                        }
                        objUser.Membership.Password = passwd;
                        objUser.Membership.Approved = PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.PublicRegistration;

                        // Create the user
                        var createStatus = UserController.CreateUser(ref objUser);

                        DataCache.ClearPortalCache(PortalId, true);

                        switch (createStatus)
                        {
                        case UserCreateStatus.Success:
                            //boNotify = true;
                            if (objUser.Membership.Approved)
                            {
                                UserController.UserLogin(this.PortalId, objUser, PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), false);
                            }
                            notifyCode = NotifyCode.ok;
                            break;

                        case UserCreateStatus.DuplicateEmail:
                            failreason = "exists";
                            break;

                        case UserCreateStatus.DuplicateUserName:
                            failreason = "exists";
                            break;

                        case UserCreateStatus.UsernameAlreadyExists:
                            failreason = "exists";
                            break;

                        case UserCreateStatus.UserAlreadyRegistered:
                            failreason = "exists";
                            break;

                        default:
                            // registration error
                            break;
                        }

                        if (notifyCode == NotifyCode.ok)
                        {
                            _profileData  = new ProfileData(objUser.UserID, rpInp, DebugMode);    //create and update a profile for this new logged in user.
                            emailtemplate = ModSettings.Get("emailregisteredtemplate");
                            if (emailtemplate != "")
                            {
                                NBrightBuyUtils.SendEmailToManager(emailtemplate, _profileData.GetProfile(), "profileregistered_emailsubject.Text");
                            }
                            emailtemplate = ModSettings.Get("emailregisteredclienttemplate");
                            if (emailtemplate != "")
                            {
                                NBrightBuyUtils.SendEmail(objUser.Email, emailtemplate, _profileData.GetProfile(), "profileregistered_emailsubject.Text", "", objUser.Profile.PreferredLocale);
                            }
                        }
                    }
                }
                else
                {
                    NBrightBuyUtils.SetFormTempData(ModuleId, GenXmlFunctions.GetGenXml(rpInp));
                    failreason = "captcha";
                }

                param[0] = "msg=" + NotifyRef + "_" + notifyCode;
                if (!UserInfo.IsInRole(StoreSettings.ClientEditorRole) && ModSettings.Get("clientrole") == "True" && notifyCode == NotifyCode.ok)
                {
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + "clientrole", notifyCode);
                }
                else
                {
                    NBrightBuyUtils.SetNotfiyMessage(ModuleId, NotifyRef + failreason, notifyCode);
                }

                if (notifyCode == NotifyCode.ok)
                {
                    redirecttabid = ModSettings.Get("ddlredirecttabid");
                }
                if (!Utils.IsNumeric(redirecttabid))
                {
                    redirecttabid = TabId.ToString("");
                }
                Response.Redirect(Globals.NavigateURL(Convert.ToInt32(redirecttabid), "", param), true);
                break;
            }
        }