protected virtual void OnUserAuthenticated(UserAuthenticatedEventArgs ea)
 {
     if (this.UserAuthenticated != null)
     {
         this.UserAuthenticated(null, ea);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// UserAuthenticated runs when the user is authenticated by one of the child
        /// Authentication controls
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        /// 	[cnurse]	07/10/2007  Created
        /// </history>
        protected void UserAuthenticated(object sender, UserAuthenticatedEventArgs e)
        {
            LoginStatus = e.LoginStatus;

            //Check the Login Status
            switch (LoginStatus)
            {
                case UserLoginStatus.LOGIN_USERNOTAPPROVED:
                    switch (e.Message)
                    {
                        case "EnterCode":
                            AddModuleMessage(e.Message, ModuleMessage.ModuleMessageType.YellowWarning, true);
                            break;
                        case "InvalidCode":
                        case "UserNotAuthorized":
                            AddModuleMessage(e.Message, ModuleMessage.ModuleMessageType.RedError, true);
                            break;
                        default:
                            AddLocalizedModuleMessage(e.Message, ModuleMessage.ModuleMessageType.RedError, true);
                            break;
                    }
                    break;
                case UserLoginStatus.LOGIN_USERLOCKEDOUT:
                    AddLocalizedModuleMessage(string.Format(Localization.GetString("UserLockedOut", LocalResourceFile), Host.AutoAccountUnlockDuration), ModuleMessage.ModuleMessageType.RedError, true);
                    //notify administrator about account lockout ( possible hack attempt )
                    var Custom = new ArrayList {e.UserToken};

                    var message = new Message
                                      {
                                          FromUserID = PortalSettings.AdministratorId,
                                          ToUserID = PortalSettings.AdministratorId,
                                          Subject = Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_SUBJECT", Localization.GlobalResourceFile, Custom),
                                          Body = Localization.GetSystemMessage(PortalSettings, "EMAIL_USER_LOCKOUT_BODY", Localization.GlobalResourceFile, Custom),
                                          Status = MessageStatusType.Unread
                                      };
                    //_messagingController.SaveMessage(_message);

                    Mail.SendEmail(PortalSettings.Email, PortalSettings.Email, message.Subject, message.Body);
                    break;
                case UserLoginStatus.LOGIN_FAILURE:
                    //A Login Failure can mean one of two things:
                    //  1 - User was authenticated by the Authentication System but is not "affiliated" with a DNN Account
                    //  2 - User was not authenticated
                    if (e.Authenticated)
                    {
                        PageNo = 1;
                        AuthenticationType = e.AuthenticationType;
                        AutoRegister = e.AutoRegister;
                        ProfileProperties = e.Profile;
                        UserToken = e.UserToken;

                        ShowPanel();
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(e.Message))
                        {
                            AddModuleMessage("LoginFailed", ModuleMessage.ModuleMessageType.RedError, true);
                        }
                        else
                        {
                            AddLocalizedModuleMessage(e.Message, ModuleMessage.ModuleMessageType.RedError, true);
                        }
                    }
                    break;
                default:
                    if (e.User != null)
                    {
                        //First update the profile (if any properties have been passed)
                        AuthenticationType = e.AuthenticationType;
                        ProfileProperties = e.Profile;
                        UpdateProfile(e.User, true);
                        ValidateUser(e.User, false);
                    }
                    break;
            }
        }
        private void OnLoginClick(object sender, EventArgs e)
        {
            if ((UseCaptcha && ctlCaptcha.IsValid) || !UseCaptcha)
            {
                var loginStatus = UserLoginStatus.LOGIN_FAILURE;
                var objUser = UserController.ValidateUser(PortalId, txtUsername.Text, txtPassword.Text, "DNN", string.Empty, PortalSettings.PortalName, IPAddress, ref loginStatus);
                var authenticated = Null.NullBoolean;
                var message = Null.NullString;
                if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
                {
                    message = "UserNotAuthorized";
                }
                else
                {
                    authenticated = (loginStatus != UserLoginStatus.LOGIN_FAILURE);
                }

                //Raise UserAuthenticated Event
                var eventArgs = new UserAuthenticatedEventArgs(objUser, txtUsername.Text, loginStatus, "DNN")
                                    {
                                        Authenticated = authenticated,
                                        Message = message,
                                        RememberMe = chkCookie.Checked
                                    };
                OnUserAuthenticated(eventArgs);
            }
        }
 protected virtual void OnUserAuthenticated(UserAuthenticatedEventArgs ea)
 {
     if (UserAuthenticated != null)
     {
         UserAuthenticated(null, ea);
     }
 }
Esempio n. 5
0
        private void UserAuthenticated(object sender, UserAuthenticatedEventArgs e)
        {
            NameValueCollection profileProperties = e.Profile;

            User.Username = e.UserToken;
            AuthenticationType = e.AuthenticationType;
            UserToken = e.UserToken;

            foreach (string key in profileProperties)
            {
                switch (key)
                {
                    case "FirstName":
                            User.FirstName = profileProperties[key];
                        break;
                    case "LastName":
                            User.LastName = profileProperties[key];
                        break;
                    case "Email":
                            User.Email = profileProperties[key];
                        break;
                    case "DisplayName":
                            User.DisplayName = profileProperties[key];
                        break;
                    default:
                        User.Profile.SetProfileProperty(key, profileProperties[key]);
                        break;
                }
            }

            //Generate a random password for the user
            User.Membership.Password = UserController.GeneratePassword();

            if (!String.IsNullOrEmpty(User.Email))
            {
                CreateUser();
            }
            else
            {
                AddLocalizedModuleMessage(LocalizeString("NoEmail"), ModuleMessage.ModuleMessageType.RedError, true);
                foreach(DnnFormItemBase formItem in userForm.Items)
                {
                    formItem.Visible = formItem.DataField == "Email";
                }
                userForm.DataBind();
            }
        }
Esempio n. 6
0
 private void DoLogon(string username, string password)
 {
     var loginStatus = UserLoginStatus.LOGIN_FAILURE;
     var objUser = UserController.ValidateUser(PortalId, username, password, "DNN", txtVerification.Text, PortalSettings.PortalName, IPAddress, ref loginStatus);
     var authenticated = Null.NullBoolean;
     var message = Null.NullString;
     if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
     {
         //Check if its the first time logging in to a verified site
         if (PortalSettings.UserRegistration == (int)Globals.PortalRegistrationType.VerifiedRegistration)
         {
             if (!divVerify.Visible)
             {
                 //Display Verification Rows so User can enter verification code
                 divVerify.Visible = true;
                 message = "EnterCode";
             }
             else
             {
                 message = !String.IsNullOrEmpty(txtVerification.Text) ? "InvalidCode" : "EnterCode";
             }
         }
         else
         {
             message = "UserNotAuthorized";
         }
     }
     else
     {
         authenticated = (loginStatus != UserLoginStatus.LOGIN_FAILURE);
     }
     //Raise UserAuthenticated Event
     var eventArgs = new UserAuthenticatedEventArgs(objUser, txtUsername.Text, loginStatus, "DNN") { Authenticated = authenticated, Message = message };
     OnUserAuthenticated(eventArgs);
 }
 protected virtual void OnUserAuthenticated(UserAuthenticatedEventArgs ea)
 {
     AuthResult = ea;
     if (ea.User != null)
     {
         if (ea.User.Profile != null && ea.User.Profile.PreferredLocale != null)
         {
             DotNetNuke.Services.Localization.Localization.SetLanguage(ea.User.Profile.PreferredLocale);
         }
         UserController.UserLogin(PortalSettings.PortalId, ea.User, PortalSettings.PortalName, GetIpAddress(),
             KeepLoggedIn);
     }
 }
Esempio n. 8
0
		private void OnLoginClick(object sender, EventArgs e)
		{
			if ((UseCaptcha && ctlCaptcha.IsValid) || !UseCaptcha)
			{
				var loginStatus = UserLoginStatus.LOGIN_FAILURE;
				string userName = new PortalSecurity().InputFilter(txtUsername.Text, 
										PortalSecurity.FilterFlag.NoScripting | 
                                        PortalSecurity.FilterFlag.NoAngleBrackets | 
                                        PortalSecurity.FilterFlag.NoMarkup);

                //DNN-6093
                //check if we use email address here rather than username
                if(PortalController.GetPortalSettingAsBoolean("Registration_UseEmailAsUserName", PortalId, false))
                {
                    var testUser = UserController.GetUserByEmail(PortalId, userName); // one additonal call to db to see if an account with that email actually exists
                    if(testUser != null)
                    {
                        userName = testUser.Username; //we need the username of the account in order to authenticate in the next step
                    }
                }

				var objUser = UserController.ValidateUser(PortalId, userName, txtPassword.Text, "DNN", string.Empty, PortalSettings.PortalName, IPAddress, ref loginStatus);
				var authenticated = Null.NullBoolean;
				var message = Null.NullString;
				if (loginStatus == UserLoginStatus.LOGIN_USERNOTAPPROVED)
				{
				    message = "UserNotAuthorized";
				}
				else
				{
					authenticated = (loginStatus != UserLoginStatus.LOGIN_FAILURE);
				}

                if (loginStatus != UserLoginStatus.LOGIN_FAILURE && PortalController.GetPortalSettingAsBoolean("Registration_UseEmailAsUserName", PortalId, false))
                {
                    //make sure internal username matches current e-mail address
                    if (objUser.Username.ToLower() != objUser.Email.ToLower())
                    {
                        UserController.ChangeUsername(objUser.UserID, objUser.Email);
                    }

                    Response.Cookies.Remove("USERNAME_CHANGED");
                }
				
				//Raise UserAuthenticated Event
				var eventArgs = new UserAuthenticatedEventArgs(objUser, userName, loginStatus, "DNN")
				                    {
				                        Authenticated = authenticated, 
                                        Message = message,
                                        RememberMe = chkCookie.Checked
				                    };
				OnUserAuthenticated(eventArgs);
			}
		}