public ActionResult Login(LoginModel user) { LoginManage userM = new LoginManage(); Model1 db = new Model1(); if (ModelState.IsValid) { User userDB = new User { Account = user.username, Password = user.Password }; if ((userM.CheckAccount(user.username) && userM.CheckPassword(Encrypt.Encrypts(user.Password))) == true) { Session["user"] = user.username; return(RedirectToAction("Index", "Home")); } else { ModelState.AddModelError("LoginFail", "Login Fail"); ViewBag.notification = "Username or Password incorrect"; } } return(View()); }
public ActionResult DeleteConfirmed(int id) { LoginManage loginManage = db.LoginManages.Find(id); db.LoginManages.Remove(loginManage); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "LoginManageKey,UserName,TimeLogin,TimeLogout")] LoginManage loginManage) { if (ModelState.IsValid) { db.Entry(loginManage).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loginManage)); }
public ActionResult Create([Bind(Include = "LoginManageKey,UserName,TimeLogin,TimeLogout")] LoginManage loginManage) { if (ModelState.IsValid) { db.LoginManages.Add(loginManage); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(loginManage)); }
public static string Insert(string temp) { JObject jo = (JObject)JsonConvert.DeserializeObject(temp); string msg; string password = LoginManage.GenerateMD5(jo["password"].ToString()); int apartID = apartment[jo["apartID"].ToString()]; int roleID = roles[jo["roleID"].ToString()]; Models.User user = new Models.User((int)jo["id"], jo["userName"].ToString(), password, apartID, jo["job"].ToString(), roleID, jo["num"].ToString(), jo["name"].ToString()); return(UserManage.Add(user, out msg) ? JsonConvert.SerializeObject(new Packet(200, "插入成功")) : JsonConvert.SerializeObject(new Packet(203, msg))); }
// GET: LoginManages/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } LoginManage loginManage = db.LoginManages.Find(id); if (loginManage == null) { return(HttpNotFound()); } return(View(loginManage)); }
protected void btn_login_Click(object sender, EventArgs e) { //封装实体对象 //封装实体对象 int UserName = Convert.ToInt32(Request.Form["txt_username"]); string PassWord = Request.Form["txt_password"].ToString(); Model.Login user = new Model.Login() { UserName = UserName, PassWord = PassWord }; //调用BLL层方法,返回一个新的user对象 user = new LoginManage().LoginService(user); //根据返回的数据进行操作 if (user == null) { Literal1.Text = "<script type='text/javascript'>alert('账号密码错误')</script>"; } else { Session["CurrentUser"] = user; if (user.type == 1) { Literal1.Text = "<script type='text/javascript'>alert('登陆成功');location.href='StudentsInfo/stu_index.aspx'</script>"; } if (user.type == 2) { Literal1.Text = "<script type='text/javascript'>alert('登陆成功');location.href='StudentsInfo/xueshengchu_index.aspx'</script>"; } if (user.type == 3) { Literal1.Text = "<script type='text/javascript'>alert('登陆成功');location.href='StudentsInfo/jiaowuchu_index.aspx'</script>"; } if (user.type == 4) { Literal1.Text = "<script type='text/javascript'>alert('登陆成功');location.href='StudentsInfo/teacherindex.aspx'</script>"; } if (user.type == 5) { Literal1.Text = "<script type='text/javascript'>alert('登陆成功');location.href='StudentsInfo/college_index.aspx'</script>"; } if (user.type == 6) { Literal1.Text = "<script type='text/javascript'>alert('登陆成功');location.href='StudentsInfo/Guanliyuan_index.aspx'</script>"; } } }
public ActionResult LogOut() { Session.Remove("kh"); Session.Remove("UserName"); FormsAuthentication.SignOut(); Session["TimeLogout"] = DateTime.Now.ToString(); LoginManage loginManage = new LoginManage(); loginManage.UserName = Session["user"].ToString(); loginManage.TimeLogin = Session["TimeLogin"].ToString(); loginManage.TimeLogout = Session["TimeLogout"].ToString(); db.LoginManages.Add(loginManage); db.SaveChanges(); return(RedirectToAction("Login", "Authentication")); }
public void ProcessRequest(HttpContext context) { var resData = new OperationResult <CustomerLoginData>(); var uid = context.Request["id"] ?? "100002"; var service = new CustomerBP(); resData = service.GetUserById(new RequestOperation <int>() { Body = int.Parse(uid), Header = new HeaderInfo() { } }); if (resData.ErrCode == 0) { LoginManage.SaveUserInfo(resData.Body.UserID); } context.Response.Redirect("index.html"); }
public static string Update(string temp) { JObject jo = (JObject)JsonConvert.DeserializeObject(temp); string msg; string password; if (jo["password"].ToString().Equals("******")) { password = null; } else { password = LoginManage.GenerateMD5(jo["password"].ToString()); } int apartID = apartment[jo["apartID"].ToString()]; int roleID = roles[jo["roleID"].ToString()]; Models.User user = new Models.User((int)jo["id"], jo["userName"].ToString(), password, apartID, jo["job"].ToString(), roleID, jo["num"].ToString(), jo["name"].ToString()); return(UserManage.Update(user, out msg) ? JsonConvert.SerializeObject(new Packet(200, "修改成功")) : JsonConvert.SerializeObject(new Packet(202, msg))); }
protected void btn_alterpass_Click(object sender, EventArgs e) { string oldPassWord = txt_pwd.Text.Trim(); string newPassWord = txt_newpwd.Text.Trim(); string newPassWord2 = txt_renewpwd.Text.Trim(); if (newPassWord != newPassWord2) { Response.Write("<script type='text/javascript'>alert('两次输入的密码不一致')</script>"); return; } int UserName = Convert.ToInt32(((Model.Login)Session["CurrentUser"]).UserName); Model.Login user = new Model.Login() { UserName = UserName, PassWord = oldPassWord }; user = new LoginManage().LoginService(user); if (user == null) { Response.Write("<script type='text/javascript'>alert('原密码错误')</script>"); return; } Model.Login newuser = new Model.Login() { UserName = UserName, PassWord = newPassWord }; int res = new LoginManage().AlterPwd(newuser); if (res > 0) { Response.Write("<script type='text/javascript'>alert('更新成功');</script>"); } else { Response.Write("<script type='text/javascript'>alert('更新失败')</script>"); } }
public void ProcessRequest(HttpContext context) { var resData = new OperationResult <CustomerLoginData>(); var cookieUser = LoginManage.GetUId(); // if (cookieUser <= 0) { resData.Message = "用户未登录"; } else { var service = new CustomerBP(); var res = service.GetUserById(new RequestOperation <int>() { Body = cookieUser, Header = new HeaderInfo() { } }); if (res.ErrCode == 0) { resData.Body = new CustomerLoginData() { UserID = res.Body.UserID, NickName = res.Body.NickName, Name = res.Body.Name, Face = res.Body.Face }; resData.ErrCode = 0; } } context.Response.Write(JsonHelper.ReBuilder(resData)); context.Response.End(); }
private void Awake() { Instance = this; }
public void ProcessRequest(HttpContext context) { var accesstoken = CookiesHelper.GetCookie(accesstokenKey); SnsOAuthAccessTokenResponse AccessToken = null; var m_client = new DefaultApiClient(); var m_appIdent = new AppIdentication(wxappid, wxappsecret); string State = context.Request["state"]; string jumpUrl = "index.html"; try { if (accesstoken == null) { string code = context.Request["Code"]; var request = new SnsOAuthAccessTokenRequest { AppID = m_appIdent.AppID, AppSecret = m_appIdent.AppSecret, Code = code }; AccessToken = m_client.Execute(request); if (AccessToken.IsError) { throw new Exception("获取网页授权accesstoken失败。" + JsonHelper.ReBuilder(request) + "\r\n" + AccessToken.ErrorMessage); } CookiesHelper.AddCookie("webpage_accesstoken", JsonHelper.ReBuilder(AccessToken), DateTime.Now.AddSeconds(AccessToken.ExpiresIn - 600)); } else { AccessToken = JsonHelper.Build <SnsOAuthAccessTokenResponse>(accesstoken.Value); } string unionid = AccessToken.UnionId; if (String.IsNullOrEmpty(unionid)) { unionid = AccessToken.OpenId; } string openid = AccessToken.OpenId; var query = new RequestOperation <string>(); query.Header = new HeaderInfo() { DeviceID = 5, DisplayName = "customer", UserID = 1 }; query.Body = unionid; var service = new CustomerBP(); var data = service.LoginByWechatAccount(query); //不存在此用户 if (data.ErrCode == 1) { var wexinInfo = new SnsUserInfoRequest { OAuthToken = AccessToken.AccessToken, OpenId = AccessToken.OpenId, Lang = Language.CN }; var userinfo_res = m_client.Execute(wexinInfo); if (userinfo_res.IsError) { throw new Exception("获取用户信息失败2。" + JsonHelper.ReBuilder(wexinInfo) + "\r\n" + JsonHelper.ReBuilder(userinfo_res)); } #region 注册 string url = HttpUtility.UrlDecode(State); int invateUserId = 0; if (!string.IsNullOrEmpty(State)) { url = domian + unescape(url); invateUserId = getInveteUser(url); } var register = new RequestOperation <RegisterData>(); register.Header = query.Header; register.Body = new RegisterData(); register.Body.Account = ""; register.Body.WechatAccount = unionid; register.Body.QQAccount = ""; register.Body.Face = userinfo_res.HeadImageUrl; register.Body.NickName = register.Body.Name = userinfo_res.NickName; register.Body.Password = "******"; var register_res = service.Register(register); if (register_res.ErrCode != 0) { throw new Exception("注册用户失败:" + register_res.Message); } LoginManage.SaveUserWeixinOpenId(userinfo_res.OpenId); LoginManage.SaveUserInfo(register_res.Body.UserID); if (!string.IsNullOrEmpty(State)) { jumpUrl = replaceInveteUserParam(url); } #endregion } else { //不准修改,此处用于微信支付!!! LoginManage.SaveUserWeixinOpenId(AccessToken.OpenId); LoginManage.SaveUserInfo(data.Body.UserID); if (!string.IsNullOrEmpty(State)) { string url = domian + HttpUtility.UrlDecode(State); jumpUrl = replaceInveteUserParam(url); } } } catch (Exception ex) { Logger.WriteException("【微信网页授权】", ex, ""); } context.Response.Redirect(jumpUrl); }
public LoginController(UserContext userContext, PhoneContext phoneContext, BrandContext brandContext, BrandTypeContext brandTypeContext, BrandTypeProductNoContext brandTypeProductNoContext, TypeYearContext typeYearContext, DeleteReasonContext deleteReasonContext) { loginManage = new LoginManage(userContext, phoneContext, brandContext, brandTypeContext, brandTypeProductNoContext, typeYearContext, deleteReasonContext); }