Beispiel #1
0
        private void AuthenticateUser()
        {
            _objuser = new clsUsers(CleanAndFormat.CleanText(txtUserName.Text, false, false), CleanAndFormat.CleanText(txtPassword.Text, false, false));
            bool isAuthenticated = false;
            try
            {
                if (IsUserAuthenticated())
                {
                    //((KarrStyle.SiteMaster)this.Master).LogUserUsage("Login", "Logon Successful");

                    FormsAuthentication.SetAuthCookie(txtUserName.Text, false);

                    Response.Redirect(_objuser.HomePage, false);
                }
            }
            catch (System.Data.SqlClient.SqlException SqlEx)
            {
                //SetInformationMessage = SqlEx.Message;
                SetErrorMessage = SqlEx.Message;
            }
            catch (Exception ex)
            {
                SetErrorMessage = ex.Message;
                throw ex;
            }
        }
Beispiel #2
0
        protected clsUsers GetUserProfile(DataSet userDetails, string userName, string userPassword)
        {
            clsUsers _objUser = null;
            DataTable authenticatedUserDetails = null;

            try
            {
                if (userDetails != null && userDetails.Tables[0].Rows.Count > 0)
                {
                    authenticatedUserDetails = userDetails.Tables[0];
                    _objUser = new clsUsers(userName, userPassword);

                    _objUser.UserID = CleanAndFormat.CleanInteger(authenticatedUserDetails.Rows[0]["UserId"]);
                    _objUser.FirstName = CleanAndFormat.CleanText(authenticatedUserDetails.Rows[0]["FirstName"]);
                    _objUser.LastName = CleanAndFormat.CleanText(authenticatedUserDetails.Rows[0]["LastName"]);
                    _objUser.UserName = CleanAndFormat.CleanText(authenticatedUserDetails.Rows[0]["UserName"]);
                    _objUser.isAdmin = CleanAndFormat.CleanInteger(authenticatedUserDetails.Rows[0]["isAdmin"]);
                    //userProfileObject.HomePage = CleanAndFormat.CleanText(authenticatedUserDetails.Rows[0]["HomePage"]);

                }
            }
            finally
            {
                if (authenticatedUserDetails != null)
                {
                    authenticatedUserDetails.Dispose();
                    authenticatedUserDetails = null;
                }

                if (userDetails != null)
                {
                    userDetails.Clear();
                    userDetails.Dispose();
                }

                userDetails = null;
            }

            return _objUser;
        }
Beispiel #3
0
        private bool IsUserAuthenticated()
        {
            clsUsers userObject = null;
            bool isAuthenticated = false;
            try
            {
                userObject = new clsUsers(CleanAndFormat.CleanText(txtUserName.Text), clsConstants.encrypPassword(txtPassword.Text.Trim()));
                userObject = userObject.ValidateUser();

                Session[clsConstants.UserProfile] = userObject;

                Response.Cookies["UName"].Value = txtUserName.Text;
                Response.Cookies["UName"].Expires = DateTime.Now.AddDays(1);
                ((SiteMaster)this.Master).UserObject = userObject;

                isAuthenticated = true;
                Response.Redirect("~/Pages/Additems.aspx");
            }
            catch (Exception ex)
            {
                SetErrorMessage = ex.Message;
                ExceptionHandler.HandleException(ex, "", KarrStyleException.ExceptionLevel.Error);
            }
            finally
            {
                userObject = null;
            }
            return isAuthenticated;
        }