Exemple #1
0
        protected void LogIn(object sender, EventArgs e)
        {
            if (IsValid)
            {
                // Validate the user password
                ProviderUserName = UserName.Text.Trim();
                ProviderPassword = Password.Text.Trim();
                var _userExists = _userInformationRT.IsUserExists(ProviderUserName, ProviderPassword);

                //var manager = new UserManager();
                //var user = _userInformationRT.FindUser(ProviderUserName, ProviderPassword);

                if (_userExists)
                {
                    //IdentityHelper.SignIn(manager, user, RememberMe.Checked);
                    IdentityHelper.RedirectToReturnUrl(Request.QueryString["ReturnUrl"], Response);
                }
                else
                {
                    FailureText.Text     = "Invalid username or password.";
                    Password.Text        = default(string);
                    ErrorMessage.Visible = true;
                }
            }
        }
        protected void OnAuthenticate(object sender, AuthenticateEventArgs e)
        {
            if (IsValid)
            {
                // Validate the user password
                e.Authenticated = false;
                Login masterLogin = (Login)masterview.FindControl("masterLogin");
                ProviderUserName = masterLogin.UserName.ToString().Trim();
                ProviderPassword = masterLogin.Password.ToString().Trim();

                var _userExists = _userInformationRT.IsUserExists(ProviderUserName, ProviderPassword);

                //var manager = new UserManager();
                //var user = _userInformationRT.FindUser(ProviderUserName, ProviderPassword);

                if (_userExists)
                {
                    //IdentityHelper.SignIn(manager, user, RememberMe.Checked);
                    e.Authenticated = true;
                    FormsAuthentication.SetAuthCookie(ProviderUserName, true);
                    masterLogin.DestinationPageUrl = "~/Default.aspx";
                }
                else
                {
                    FailureText.Text = "Invalid username or password.";
                    //masterLogin.Password = default(string);
                    ErrorMessage.Visible = true;
                }
            }
        }
        protected void LogIn(object sender, EventArgs e)
        {
            try
            {
                if (IsValid)
                {
                    ProviderUserName = UserName.Text.Trim();
                    ProviderPassword = StringCipher.Encrypt(Password.Text.Trim());

                    var _userExists = _userInformationRT.IsUserExists(ProviderUserName, ProviderPassword);
                    var _findUser   = _userInformationRT.FindUser(ProviderUserName, ProviderPassword);

                    if (_userExists)
                    {
                        var objUserGroup = _userInformationRT.FindUserGroup(_findUser != null ? _findUser.UserGroupID : default(Int64));

                        FormsAuthentication.SetAuthCookie(ProviderUserName, true);
                        Session["LoginStatus"] = "Log out";
                        Session["UserName"]    = ProviderUserName;

                        if (objUserGroup != null)
                        {
                            if (Convert.ToInt32(objUserGroup.TypeID) == Convert.ToInt32(OH.Utilities.EnumCollection.UserGrpType.Management) || Convert.ToInt32(objUserGroup.TypeID) == Convert.ToInt32(OH.Utilities.EnumCollection.UserGrpType.Control_User))
                            {
                                Response.Redirect("~/ControlAdmin/AdminDefault.aspx");
                            }
                            else if (Convert.ToInt32(objUserGroup.TypeID) == Convert.ToInt32(OH.Utilities.EnumCollection.UserGrpType.Add_Giver))
                            {
                                Response.Redirect("~/MaterialWF.aspx");
                            }
                            else
                            {
                                Response.Redirect("~/Default.aspx");
                            }
                        }
                    }
                    else
                    {
                        Session["LoginStatus"] = "Login";
                        FailureText.Text       = "Invalid username or password.";
                        Password.Text          = default(string);
                        ErrorMessage.Visible   = true;
                        //Response.Redirect("~/LoginPage.aspx");
                    }
                }
            }
            catch (Exception ex)
            {
            }
        }