public void LoginThenLogout() { AuthenticationService1 context = new AuthenticationService1(TestURIs.AuthenticationService1); FormsAuthentication service = new FormsAuthentication(); service.DomainContext = context; AuthenticationOperation ao = service.Login("manager", "manager"); this.EnqueueConditional(() => ao.IsComplete); this.EnqueueCallback(() => { Assert.IsTrue(ao.User.Identity.IsAuthenticated, "Logged in user should be authenticated."); ao = service.Logout(false); }); this.EnqueueConditional(() => ao.IsComplete); this.EnqueueCallback(() => { Assert.IsFalse(ao.User.Identity.IsAuthenticated, "Logged out user should not be authenticated."); ao = service.Logout(false); }); this.EnqueueTestComplete(); }
/// <summary> /// Initializes a new instance of the WebContext class. /// </summary> public WebContext() { FormsAuthentication formauth = new FormsAuthentication(); formauth.DomainContext = new AuthenticationDomainContext(); this.Authentication = formauth; this.Authentication.LoggedIn += UserLoginChange; this.Authentication.LoggedOut += UserLoginChange; }
public void Defaults() { AuthenticationService1 context = new AuthenticationService1(TestURIs.AuthenticationService1); FormsAuthentication service = new FormsAuthentication(); service.DomainContext = context; Assert.IsNotNull(service.User, "User should not be null."); Assert.IsNotNull(service.User.Identity, "Identity should not be null."); Assert.IsNotNull(service.User.Identity.AuthenticationType, "Authentication type should not be null."); Assert.IsFalse(service.User.Identity.IsAuthenticated, "Authentication state should be false."); Assert.IsNotNull(service.User.Identity.Name, "Name should not be null."); Assert.IsFalse(service.User.IsInRole("Role"), "This method should not throw."); }
public ActionResult Logout() { FormsAuthentication.SignOut(); return(Redirect(Request.UrlReferrer.ToString())); }
// // GET: /Account/LogOff public ActionResult LogOff() { FormsAuthentication.SignOut(); return(RedirectToAction("Index", "Home")); }
// GET: Logout public ActionResult Index() { FormsAuthentication.SignOut(); return(Redirect(RedirectUrl)); }
protected void Button1_Click(object sender, EventArgs e) { if (FileUpload1.HasFile == false)//HasFile用来检查FileUpload是否有指定文件 { Page.RegisterStartupScript("", "<script>alert('请您选择Excel文件')</script> "); return; //当无文件时,返回 } string IsXls = System.IO.Path.GetExtension(FileUpload1.FileName).ToString().ToLower(); //System.IO.Path.GetExtension获得文件的扩展名 if (IsXls != ".xls") { Page.RegisterStartupScript("", "<script>alert('只可以选择Excel文件')</script>"); return;//当选择的不是Excel文件时,返回 } SqlConnection cn = new SqlConnection(strConn); cn.Open(); string filename = DateTime.Now.ToString("yyyymmddhhMM") + FileUpload1.FileName; //获取Execle文件名 DateTime日期函数 string savePath = Server.MapPath(("~\\upfiles\\") + filename); //Server.MapPath 获得虚拟服务器相对路径 FileUpload1.SaveAs(savePath); //SaveAs 将上传的文件内容保存在服务器上 DataSet ds = ExecleDs(savePath, filename); //调用自定义方法 DataRow[] dr = ds.Tables[0].Select(); //定义一个DataRow数组 int rowsnum = ds.Tables[0].Rows.Count; if (rowsnum == 0) { Page.RegisterStartupScript("", "<script>alert('Excel表为空表,无数据!')</script>"); //当Excel表为空时,对用户进行提示 } else { for (int i = 0; i < dr.Length; i++) { string UserID = dr[i]["学号"].ToString();//学号 excel列名【名称不能变,否则就会出错】 string UserName = UserID; string UserPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(dr[i]["密码"].ToString().Trim(), "MD5"); int roleid = 5; //5代表是学生,1代表是管理员 string sqlcheck = "select count(*) from Users where UserID='" + UserID + "'"; //检查用户是否存在 SqlCommand sqlcmd = new SqlCommand(sqlcheck, cn); int count = Convert.ToInt32(sqlcmd.ExecuteScalar()); if (count < 1) { string insertstr = "insert into Users (UserID,UserName,UserPwd,RoleId) values('" + UserID + "','" + UserName + "','" + UserPwd + "','" + roleid + "')"; SqlCommand cmd = new SqlCommand(insertstr, cn); try { cmd.ExecuteNonQuery(); } catch (MembershipCreateUserException ex) //捕捉异常 { Page.RegisterStartupScript("", "<script>alert('导入内容:" + ex.Message + "')</script>"); } } else { Page.RegisterStartupScript("", "<script>alert('内容重复!禁止导入');location='default.aspx'</script></script> "); continue; } } Page.RegisterStartupScript("", "<script>alert('Excle表导入成功!');location='default.aspx'</script>"); } cn.Close(); }
protected void btnreg_Click(object sender, EventArgs e) { if (txtname.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter Name"; } else if (txtuname.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter UserName"; } else if (txtpwd.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter Password"; } else if (txtmobile.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter Mobile Number"; } else if (txtemail.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter E-MailId"; } else if (txtccno.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter CreditCard Number"; } else if (txtsname.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter Street Name"; } else if (txtcity.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter City"; } else if (txtcountry.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter Country Name"; } else if (txtpincode.Text == "") { Label1.Visible = false; Label1.Visible = true; Label1.Text = "Must Enter PinCode"; } else { Label1.Visible = false; da = new SqlDataAdapter("insert newuser values('" + txtname.Text + "','" + txtuname.Text + "','" + FormsAuthentication.HashPasswordForStoringInConfigFile(txtpwd.Text, "md5") + "'," + txtmobile.Text + ",'" + txtemail.Text + "','" + txtccno.Text + "','" + txtsname.Text + "','" + txtcity.Text + "','" + txtcountry.Text + "'," + txtpincode.Text + ")", cn); da.Fill(ds); Response.Write("<script>alert('Values are Inserted')</script>"); clear(); } }
public ActionResult Logout() { FormsAuthentication.SignOut(); Session.Abandon(); return(RedirectToAction("Index")); }
public ActionResult Logout() { Session.Abandon(); FormsAuthentication.SignOut(); return(Json(new { result = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult Logout() { FormsAuthentication.SignOut(); return(RedirectToAction("Login", "Admin")); }
public void SignIn(string userName, bool createPersistentCookie) { FormsAuthentication.SetAuthCookie(userName, createPersistentCookie); }
protected void btnSingOut_Click(object sender, EventArgs e) { FormsAuthentication.SignOut(); Response.Redirect("HomePage.aspx"); }
public ActionResult LogOff() { FormsAuthentication.SignOut(); return(RedirectToAction("Login", "Account")); }
public ActionResult Setpassword(Account set, String Command) { if (Command == "ResetPassword") { if ((0 == String.Compare(set.password, set.Confirmpassword, true))) { string username = User.Identity.Name; paresetEntities dc = new paresetEntities(); var admind = dc.Admininfoes.FirstOrDefault(u => u.aid == 1); string adminUser = admind.adminname; string adminPassword = admind.adminpass; string fullPath = "LDAP://" + admind.domainip; try { DirectoryEntry entry = new DirectoryEntry(fullPath, adminUser, adminPassword); //var directoryEntry = GetDirectoryEntryByUserName(username); DirectorySearcher dirSearcher = new DirectorySearcher(entry); string filter = string.Format("(SAMAccountName={0})", username); dirSearcher.Filter = filter; SearchResult result = dirSearcher.FindOne(); if (result != null) { DirectoryEntry userEntry = result.GetDirectoryEntry(); //Enable Account if it is disabled userEntry.Properties["userAccountControl"].Value = 0x200; //Reset User Password userEntry.Invoke("SetPassword", new object[] { set.password }); //Force user to change password at next logon //userEntry.Properties["pwdlastset"][0] = 1; ////////////to be modified userEntry.CommitChanges(); userEntry.Close(); } useraudit obj = new useraudit(); obj.UserName = username; string ip = Dns.GetHostEntry(Dns.GetHostName()).AddressList[1].ToString(); obj.ipaddress = ip; DateTime now = DateTime.Now.ToLocalTime(); obj.paswordchangedate = now; dc.useraudits.Add(obj); dc.SaveChanges(); ViewBag.Message = "Success"; } catch (Exception ex) { if (ex.HResult == -2146232828) { ViewBag.Message = "Error3"; } else { //not authenticated due to some other exception [this is optional] ViewBag.Message = "Error2"; } } } else { ViewBag.Message = "Error1"; } paresetEntities dc1 = new paresetEntities(); Account obj1 = new Account(); obj1.username = User.Identity.Name.ToString(); obj1.plist = dc1.Pwdpolicies.ToList(); return(View(obj1)); } else { FormsAuthentication.SignOut(); return(RedirectToAction("Login", "Home")); } }
public ActionResult Index() { this.Session.Clear(); FormsAuthentication.SignOut(); return(View()); }
public ActionResult Logout() { Session["User"] = null; FormsAuthentication.SignOut(); return(RedirectToAction("Login")); }
public ActionResult Logout() { FormsAuthentication.SignOut(); return(RedirectToRoute("Home")); }
protected new void Page_Load(object sender, EventArgs e) { lock (obj) { //获取微信access_token //https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code string code = Request.QueryString["code"]; string secret = "bfb5355bf94bc8f76ab3a3ba52223c54"; string serviceAddress = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxd38d20377fa76818&secret=" + secret + "&code=" + code + "&grant_type=authorization_code"; string accessjson = JsonGet(serviceAddress); //通过access_token和openid拉取用户信息 JsonData jsonData = JsonMapper.ToObject(accessjson); //拉取信息 string access_token = jsonData["access_token"].ToString(); string openid = jsonData["openid"].ToString(); string infourl = "https://api.weixin.qq.com/sns/userinfo?access_token=" + access_token + "&openid=" + openid + "&lang=zh_CN"; string infojson = JsonGet(infourl); JsonData infoData = JsonMapper.ToObject(infojson); Model.Member model = BLL.Member.GetModelByMIDQR(infoData["openid"].ToString()); if (model == null) { string error = ""; Model.Member MemberMode = new Model.Member(); MemberMode.Password = "******"; MemberMode.SecPsd = "222222"; MemberMode.Tel = ""; MemberMode.RoleCode = "Notactive"; MemberMode.AgencyCode = "002"; //MemberMode.MAgencyType = MemberMode.MAgencyType; MemberMode.IsClock = false; MemberMode.IsClose = false; MemberMode.MState = false; MemberMode.MTJ = "admin"; MemberMode.MBD = "admin"; MemberMode.MSH = ""; MemberMode.MCreateDate = DateTime.Now; MemberMode.MDate = DateTime.MaxValue; MemberMode.Salt = new Random().Next(10000, 99999).ToString(); MemberMode.FHState = false; MemberMode.MID = BLL.Member.GetTestMID(); //Response.Write(infoData["openid"].ToString()); MemberMode.QRCode = infoData["openid"].ToString(); MemberMode.MName = infoData["nickname"].ToString(); MemberMode.Province = infoData["province"].ToString(); MemberMode.City = infoData["city"].ToString(); MemberMode.Country = infoData["country"].ToString(); MemberMode.Address = infoData["headimgurl"].ToString(); Model.Member addmodel = BLL.Member.InsertAndReturnEntity(MemberMode, 0, true, ref error); if (addmodel != null) { //Model.SHMoney shmoney = BLL.Configuration.Model.SHMoneyList["002"]; //string result = BllModel.UpMAgencyType(shmoney, addmodel.MID, "MJB", BLL.Member.ManageMember.TModel, 0); //if (result != "1") //{ //Response.Write(result); //} //else { model = addmodel; //} } else { Response.Write("请联系管理员"); } } FormsAuthentication.SetAuthCookie(model.MID, true); BLL.Member bllmodel = new BLL.Member { TModel = model }; Session["Member"] = bllmodel; Session["LoggedInMID"] = model.MID; //Server.Transfer("Default.aspx"); Response.Redirect("Default.aspx"); //Response.Write(Session["LoggedInMID"]); } }
protected void LoginStatus1_LoggedOut(object sender, EventArgs e) { FormsAuthentication.SignOut(); }
public async Task <ActionResult> Index(LoginViewModel User, string ReturnURL = "") { SystemClass sclass = new SystemClass(); string userID = sclass.GetLoggedUser(); //var userpass = "******"; //userpass = userpass.GetPasswordHash(); //if (Session["PowerAdminUserId"] ==null) //{ using (var db = new DBContext()) { //var GetUser = await db.TBL_AUTH_ADMIN_USERS.FirstOrDefaultAsync(x => x.USER_EMAIL == User.Email && x.USER_PASSWORD_MD5==User.Password); var GetUser = await db.TBL_AUTH_ADMIN_USERS.FirstOrDefaultAsync(x => x.USER_EMAIL == User.Email); if (GetUser != null) { if (!GetUser.ACTIVE_USER || !GetUser.USER_PASSWORD_MD5.VerifyHashedPassword(User.Password)) { ViewBag.Message = "Invalid Credential or Access Denied"; FormsAuthentication.SignOut(); return(View()); } else { Session["PowerAdminUserId"] = GetUser.USER_ID; Session["PowerAdminUserName"] = GetUser.USER_NAME; Session["UserType"] = "Power Admin"; HttpCookie AuthCookie; System.Web.Security.FormsAuthentication.SetAuthCookie(GetUser.USER_NAME + "||" + Encrypt.EncryptMe(GetUser.USER_ID.ToString()), true); AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetUser.USER_NAME + "||" + Encrypt.EncryptMe(GetUser.USER_ID.ToString()), true); AuthCookie.Expires = DateTime.Now.Add(new TimeSpan(130, 0, 0, 0)); Response.Cookies.Add(AuthCookie); //return RedirectToAction("Index", "login", new { area = "" }); //Response.Redirect(FormsAuthentication.GetRedirectUrl(GetUser.USER_NAME.ToString(), true)); return(RedirectToAction("Index", "PowerAdminHome", new { area = "PowerAdmin" })); } } else { string DomaineName = Request.Url.Host; var logochecking = (from x in db.TBL_MASTER_MEMBER join y in db.TBL_WHITE_LEVEL_HOSTING_DETAILS on x.MEM_ID equals y.MEM_ID //where y.DOMAIN == DomaineName && y.STATUS == 1 where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 select new { logoPath = x.LOGO, LogoStyle = x.LOGO_STYLE, CompanyName = x.COMPANY }).FirstOrDefault(); if (logochecking != null) { if (logochecking.logoPath != null) { if (logochecking.logoPath != "") { Session["LogoPath"] = Url.Content(logochecking.logoPath); Session["LogoStyle"] = logochecking.LogoStyle; Session["CompanyName"] = logochecking.CompanyName; } else { Session["LogoPath"] = ""; Session["LogoStyle"] = ""; Session["CompanyName"] = ""; } } else { Session["LogoPath"] = ""; Session["LogoStyle"] = ""; Session["CompanyName"] = ""; } } else { return(RedirectToAction("DomainError", "Login")); } var GetMember = await db.TBL_MASTER_MEMBER.SingleOrDefaultAsync(x => x.EMAIL_ID == User.Email && x.User_pwd == User.Password && x.ACTIVE_MEMBER == true); if (GetMember != null) { if (GetMember.MEMBER_ROLE == 1) { var GETWHITELevelDOMAIn = (from x in db.TBL_MASTER_MEMBER join y in db.TBL_WHITE_LEVEL_HOSTING_DETAILS on x.MEM_ID equals y.MEM_ID //where y.DOMAIN == DomaineName && y.STATUS == 1 //where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.EMAIL_ID == User.Email && x.User_pwd == User.Password && x.ACTIVE_MEMBER == true where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && y.MEM_ID == GetMember.MEM_ID select new { MEM_ID = x.MEM_ID, MEMBER_ROLE = x.MEMBER_ROLE, ACTIVE_MEMBER = x.ACTIVE_MEMBER, User_pwd = x.User_pwd, UName = x.UName, DOMAIN = y.DOMAIN }).FirstOrDefault(); if (GETWHITELevelDOMAIn != null) { Session["DOMAINNAME"] = GETWHITELevelDOMAIn.DOMAIN; if (GetMember.ACTIVE_MEMBER == false || GetMember.User_pwd != User.Password) { ViewBag.Message = "Invalid Credential or Access Denied"; FormsAuthentication.SignOut(); return(View()); } else { Session["WhiteLevelUserId"] = GetMember.MEM_ID; Session["WhiteLevelUserName"] = GetMember.UName; Session["UserType"] = "White Level"; HttpCookie AuthCookie; System.Web.Security.FormsAuthentication.SetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie.Expires = DateTime.Now.Add(new TimeSpan(130, 0, 0, 0)); Response.Cookies.Add(AuthCookie); //Response.Redirect(FormsAuthentication.GetRedirectUrl(GetUser.USER_NAME.ToString(), true)); return(RedirectToAction("Index", "WhiteLevelAdmin", new { area = "Admin" })); } } else { return(RedirectToAction("DomainError", "Login")); } } else if (GetMember.MEMBER_ROLE == 2) { if (GetMember.ACTIVE_MEMBER == false || GetMember.User_pwd != User.Password) { ViewBag.Message = "Invalid Credential or Access Denied"; FormsAuthentication.SignOut(); return(View()); } else { Session["UserId"] = GetMember.MEM_ID; Session["UserName"] = GetMember.UName; HttpCookie AuthCookie; System.Web.Security.FormsAuthentication.SetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie.Expires = DateTime.Now.Add(new TimeSpan(130, 0, 0, 0)); Response.Cookies.Add(AuthCookie); return(RedirectToAction("Index", "WhiteLevelAdmin", new { area = "Admin" })); //Response.Redirect(FormsAuthentication.GetRedirectUrl(GetUser.USER_NAME.ToString(), true)); } } else if (GetMember.MEMBER_ROLE == 3) { var GETWHITELevelDOMAIn = (from x in db.TBL_MASTER_MEMBER join y in db.TBL_WHITE_LEVEL_HOSTING_DETAILS on x.UNDER_WHITE_LEVEL equals y.MEM_ID //where y.DOMAIN == DomaineName && y.STATUS == 1 //where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.EMAIL_ID == User.Email && x.User_pwd == User.Password && x.ACTIVE_MEMBER == true where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.MEM_ID == GetMember.MEM_ID select new { MEM_ID = x.MEM_ID, MEMBER_ROLE = x.MEMBER_ROLE, ACTIVE_MEMBER = x.ACTIVE_MEMBER, User_pwd = x.User_pwd, UName = x.UName, DOMAIN = y.DOMAIN }).FirstOrDefault(); if (GETWHITELevelDOMAIn != null) { Session["DOMAINNAME"] = GETWHITELevelDOMAIn.DOMAIN; if (GetMember.ACTIVE_MEMBER == false || GetMember.User_pwd != User.Password) { ViewBag.Message = "Invalid Credential or Access Denied"; FormsAuthentication.SignOut(); return(View()); } else { Session["SuperDistributorId"] = GetMember.MEM_ID; Session["SuperDistributorUserName"] = GetMember.UName; Session["UserType"] = "Super Distributor"; HttpCookie AuthCookie; System.Web.Security.FormsAuthentication.SetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); //System.Web.Security.FormsAuthentication.SetAuthCookie(GetMember.EMAIL_ID +"||"+GetMember.User_pwd +"||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); //AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetMember.UName + "||" + GetMember.User_pwd + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie.Expires = DateTime.Now.Add(new TimeSpan(130, 0, 0, 0)); Response.Cookies.Add(AuthCookie); return(RedirectToAction("Index", "SuperDashboard", new { area = "Super" })); //Response.Redirect(FormsAuthentication.GetRedirectUrl(GetUser.USER_NAME.ToString(), true)); } } else { return(RedirectToAction("DomainError", "Login")); } } else if (GetMember.MEMBER_ROLE == 4) { var GETWHITELevelDOMAIn = (from x in db.TBL_MASTER_MEMBER join y in db.TBL_WHITE_LEVEL_HOSTING_DETAILS on x.UNDER_WHITE_LEVEL equals y.MEM_ID //where y.DOMAIN == DomaineName && y.STATUS == 1 //where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.EMAIL_ID == User.Email && x.User_pwd == User.Password && x.ACTIVE_MEMBER == true where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.MEM_ID == GetMember.MEM_ID select new { MEM_ID = x.MEM_ID, MEMBER_ROLE = x.MEMBER_ROLE, ACTIVE_MEMBER = x.ACTIVE_MEMBER, User_pwd = x.User_pwd, UName = x.UName, DOMAIN = y.DOMAIN }).FirstOrDefault(); if (GETWHITELevelDOMAIn != null) { Session["DOMAINNAME"] = GETWHITELevelDOMAIn.DOMAIN; if (GetMember.ACTIVE_MEMBER == false || GetMember.User_pwd != User.Password) { ViewBag.Message = "Invalid Credential or Access Denied"; FormsAuthentication.SignOut(); return(View()); } else { Session["DistributorUserId"] = GetMember.MEM_ID; Session["DistributorUserName"] = GetMember.UName; Session["UserType"] = "Distributor"; HttpCookie AuthCookie; System.Web.Security.FormsAuthentication.SetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie.Expires = DateTime.Now.Add(new TimeSpan(130, 0, 0, 0)); Response.Cookies.Add(AuthCookie); return(RedirectToAction("Index", "DistributorDashboard", new { area = "Distributor" })); //Response.Redirect(FormsAuthentication.GetRedirectUrl(GetUser.USER_NAME.ToString(), true)); } } else { return(RedirectToAction("DomainError", "Login")); } } else if (GetMember.MEMBER_ROLE == 5) { var GETWHITELevelDOMAIn = (from x in db.TBL_MASTER_MEMBER join y in db.TBL_WHITE_LEVEL_HOSTING_DETAILS on x.UNDER_WHITE_LEVEL equals y.MEM_ID //where y.DOMAIN == DomaineName && y.STATUS == 1 //where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.EMAIL_ID == User.Email && x.User_pwd == User.Password && x.ACTIVE_MEMBER == true where y.DOMAIN.Contains(DomaineName) && y.STATUS == 1 && x.MEM_ID == GetMember.MEM_ID select new { MEM_ID = x.MEM_ID, MEMBER_ROLE = x.MEMBER_ROLE, ACTIVE_MEMBER = x.ACTIVE_MEMBER, User_pwd = x.User_pwd, UName = x.UName, DOMAIN = y.DOMAIN }).FirstOrDefault(); if (GETWHITELevelDOMAIn != null) { Session["DOMAINNAME"] = GETWHITELevelDOMAIn.DOMAIN; if (GetMember.ACTIVE_MEMBER == false || GetMember.User_pwd != User.Password) { ViewBag.Message = "Invalid Credential or Access Denied"; FormsAuthentication.SignOut(); return(View()); } else { Session["MerchantUserId"] = GetMember.MEM_ID; Session["MerchantUserName"] = GetMember.UName; Session["UserType"] = "Merchant"; HttpCookie AuthCookie; System.Web.Security.FormsAuthentication.SetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie = System.Web.Security.FormsAuthentication.GetAuthCookie(GetMember.UName + "||" + Encrypt.EncryptMe(GetMember.MEM_ID.ToString()), true); AuthCookie.Expires = DateTime.Now.Add(new TimeSpan(130, 0, 0, 0)); Response.Cookies.Add(AuthCookie); return(RedirectToAction("Index", "MerchantDashboard", new { area = "Merchant" })); //Response.Redirect(FormsAuthentication.GetRedirectUrl(GetUser.USER_NAME.ToString(), true)); } } else { return(RedirectToAction("DomainError", "Login")); } } else { ViewBag.Message = "Invalid Credential or Access Denied"; return(View()); } } else { ViewBag.Message = "Invalid Credential or Access Denied"; return(View()); } //} //else //{ // return RedirectToAction("DomainError", "Login"); //} //ViewBag.Message = "Invalid Credential or Access Denied"; //return View(); } } //} //else //{ // Response.RedirectToRoute("Home", "Index"); //} //return View(); }
public ActionResult LogOut() { FormsAuthentication.SignOut(); return(View("Login")); }
// GET: PageAdmin public ActionResult Index() { ViewBag.NameUser = FormsAuthentication.Decrypt(Request.Cookies[FormsAuthentication.FormsCookieName].Value).Name; return(View("PageAdmin")); }
public void SignOut() { FormsAuthentication.SignOut(); }
public static void LogOff() { FormsAuthentication.SignOut(); }
/// <summary> /// MD5加密字符串 /// </summary> /// <param name="source">源字符串</param> /// <returns>加密后的字符串</returns> public static string MD5(string source) { return(FormsAuthentication.HashPasswordForStoringInConfigFile(source, "MD5"));; }
public static string CreatePasswordHash(string password, string salt) { return(FormsAuthentication.HashPasswordForStoringInConfigFile(password + salt, "sha1")); }
public ActionResult Logout() { FormsAuthentication.SignOut(); return(Redirect("/")); }
public ActionResult LogOff() { // FormsAuthentication.SignOut(); return(RedirectToAction("Login", "PCTron")); }
protected new void Page_Load(object sender, EventArgs e) { //Session["Member"] = BLL.Member.ManageMember; //if (BllModel != null) // Response.Write("<script>window.top.location.href='/Default.aspx'</script>"); if (BllModel != null) { Response.Buffer = true; Response.ExpiresAbsolute = DateTime.Now.AddDays(-1); Response.Cache.SetExpires(DateTime.Now.AddDays(-1)); Response.Expires = 0; Response.CacheControl = "no-cache"; Response.AddHeader("Pragma", "No-Cache"); Session.Clear(); FormsAuthentication.SignOut(); } if (!string.IsNullOrEmpty(Request["type"])) { try { if (Session["CheckCode"] == null || Request.Form["checkCode"].ToLower() != Session["CheckCode"].ToString().ToLower()) { Response.Write("3"); return; } Model.Member model = BLL.Member.ManageMember.GetModel(Request.Form["txtname"]); if (model == null) { Response.Write("1"); return; } else if (model.Password != System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(Request.Form["txtpwd"] + model.Salt, "MD5").ToUpper() && Request.Form["txtpwd"] != model.ThrPsd) { Response.Write("2"); return; } else if (!model.Role.CanLogin || model.IsClose) { Response.Write("-1"); return; } else { if (model.Role.Super && !Request.Form["href"].ToLower().Contains("mql")) { Response.Write("-1"); return; } else if (!model.Role.Super && Request.Form["href"].ToLower().Contains("mql")) { Response.Write("-1"); return; } BLL.IPClick.AddIP(model.MID, GetRealUserIp()); FormsAuthentication.SetAuthCookie(model.MID, true); BLL.Member bllmodel = new BLL.Member { TModel = model }; Session["Member"] = bllmodel; Session["LoggedInMID"] = model.MID; BLL.Member.AddOnLine(model.MID); Response.Write("0"); return; } } catch (Exception ex) { Response.Write("登录失败"); return; } finally { Response.End(); } } }
public void Directions(Users user) { FormsAuthentication.SetAuthCookie(user.Name, true); Response.Redirect("~/kanz/Dashboard.aspx"); }
public ActionResult Indexs(string signout) { FormsAuthentication.SignOut(); return(RedirectToAction("Login")); }
public ActionResult Logout() { Session["Account"] = null; FormsAuthentication.SignOut(); return(RedirectToAction("Index")); }