protected void check_login(string Username, string Password) { if (Username == string.Empty) { string scriptCode = "<script>alert('Username is not empty.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); } else if (Password == string.Empty) { string scriptCode = "<script>alert('Password is not empty.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); } else if (Username == string.Empty && Password == string.Empty) { string scriptCode = "<script>alert('Username and Password are not empty.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); } else { string[] array_list = new string[10]; UserController users_obj = new UserController(); array_list = users_obj.CheckLogin(Username, Password); string ApplicationId = array_list[0].ToString(); string UserId = array_list[1].ToString(); string RoleId = array_list[2].ToString(); string PortalId = array_list[3].ToString(); string VendorId = array_list[4].ToString(); string HomeDirectory = array_list[5].ToString(); string IsSuperUser = array_list[6].ToString(); string UpdatePassword = array_list[7].ToString(); string IsDeleted = array_list[8].ToString(); string Status = array_list[9].ToString(); string scriptCode = string.Empty; switch (Status) { case "-1": scriptCode = "<script>alert('Username or password is empty.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); break; case "-2": scriptCode = "<script>alert('Username or password is incorrect.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); break; case "-3": scriptCode = "<script>alert('Error to write log.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); break; case "1": Session["ApplicationId"] = ApplicationId; Session["UserId"] = UserId; Session["RoleId"] = RoleId; Session["PortalId"] = PortalId; Session["VendorId"] = VendorId; Session["IsSuperUser"] = IsSuperUser; Session["UpdatePassword"] = UpdatePassword; Session["IsDeleted"] = IsDeleted; Session["UserName"] = Username; Session["HomeDirectory"] = HomeDirectory; Session.Timeout = 216000; if (chkRemmberMe.Checked == true) { WriteCookies(UserId, Username, Password); } else { DeleteCookies(); } //users_obj.CreateSessionLog(UserID, Username); string portal_url = "~/" + HomeDirectory + "/index.aspx"; Response.Redirect(portal_url); break; case "2": scriptCode = "<script>alert('Username or password has not yet activated.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); break; case "3": scriptCode = "<script>alert('Username or password is blocked.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); break; default: scriptCode = "<script>alert('System Error.');document.location='login.aspx'</script>"; Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptName", scriptCode); break; } } }
protected void check_login(string Username, string Password) { string[] array_list = new string[10]; UserController users_obj = new UserController(); array_list = users_obj.CheckLogin(Username, Password); string ApplicationId = array_list[0].ToString(); string UserId = array_list[1].ToString(); string RoleId = array_list[2].ToString(); string PortalId = array_list[3].ToString(); string VendorId = array_list[4].ToString(); string HomeDirectory = array_list[5].ToString(); string IsSuperUser = array_list[6].ToString(); string UpdatePassword = array_list[7].ToString(); string IsDeleted = array_list[8].ToString(); string Status = array_list[9].ToString(); switch (Status) { case "-1": Response.Write("<script>alert('Username or password is empty');document.location='login'</script>"); Response.End(); break; case "-2": Response.Write("<script>alert('Username or password is incorrect');document.location='login'</script>"); Response.End(); break; case "-3": Response.Write("<script>alert('Error to write log');document.location='login'</script>"); Response.End(); break; case "1": Session["ApplicationId"] = ApplicationId; Session["UserId"] = UserId; Session["RoleId"] = RoleId; Session["PortalId"] = PortalId; Session["VendorId"] = VendorId; Session["IsSuperUser"] = IsSuperUser; Session["UpdatePassword"] = UpdatePassword; Session["IsDeleted"] = IsDeleted; Session["UserName"] = Username; Session["HomeDirectory"] = HomeDirectory; Session.Timeout = 216000; if (chkRemmberMe.Checked) WriteCookies(Username, Password, UserId, RoleId, PortalId, VendorId, IsSuperUser, UpdatePassword, IsDeleted, HomeDirectory); else DeleteCookies(); //users_obj.CreateSessionLog(UserId, Username); //GetVirtualPath(RequestContext, RouteValueDictionary) //Response.RedirectToRoutePermanent("admin_index", new { tabid = "13"}); Response.RedirectToRoutePermanent("admin_index_tabid", new { tabid = "13" }); break; case "2": Response.Write("<script>alert('Username or password has not yet activated');document.location='login'</script>"); Response.End(); break; case "3": Response.Write("<script>alert('Username or password is blocked');document.location='login'</script>"); Response.End(); break; default: Response.Write("<script>alert('System Error');document.location='login'</script>"); Response.End(); break; } }