/// <summary> /// cmdAssociate_Click runs when the associate button is clicked /// </summary> /// <remarks> /// </remarks> /// <history> /// [cnurse] 07/12/2007 Created /// </history> protected void cmdAssociate_Click(object sender, EventArgs e) { if ((UseCaptcha && ctlCaptcha.IsValid) || (!UseCaptcha)) { UserLoginStatus loginStatus = UserLoginStatus.LOGIN_FAILURE; UserInfo objUser = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, "DNN", "", PortalSettings.PortalName, AuthenticationLoginBase.GetIPAddress(), ref loginStatus); if (loginStatus == UserLoginStatus.LOGIN_SUCCESS) { //Assocate alternate Login with User and proceed with Login AuthenticationController.AddUserAuthentication(objUser.UserID, AuthenticationType, UserToken); if (objUser != null) { UpdateProfile(objUser, true); } ValidateUser(objUser, true); } else { AddModuleMessage("AssociationFailed", ModuleMessage.ModuleMessageType.RedError, true); } } }
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); }
/// ----------------------------------------------------------------------------- /// <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> /// <history> /// [cnurse] 03/15/2006 /// [cnurse] 07/03/2007 Moved from Sign.ascx.vb /// </history> /// ----------------------------------------------------------------------------- private void ValidateUser(UserInfo objUser, bool ignoreExpiring) { UserValidStatus validStatus = UserValidStatus.VALID; string strMessage = Null.NullString; DateTime expiryDate = Null.NullDate; if (!objUser.IsSuperUser) { 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(), chkCookie.Checked); //redirect browser 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: //Admin has forced profile update AddModuleMessage("ProfileUpdate", ModuleMessage.ModuleMessageType.YellowWarning, true); PageNo = 3; break; } ShowPanel(); }
/// ----------------------------------------------------------------------------- /// <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(); }
/// ----------------------------------------------------------------------------- /// <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; } }
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; } }