public ActionResult ValidLoginProcess(Models.LoginInfo li) { if (li.Phone == null) { return(RedirectToAction("Index", new { msg = "請輸入手機號碼" })); } if (li.PW == null) { return(RedirectToAction("Index", new { msg = "請輸入密碼" })); } DB.DB mydb = new DB.DB(); DB.ICustomer ic = new DB.Impl_Customer(mydb.Connection); if (ic.CheckLogin(li.Phone, li.PW)) { Session.Add("Login", li.Phone); Session.Add("LoginType", "c"); // 取出User原先瀏覽的網頁 HttpCookie hc = Request.Cookies["ReUrl"]; if (hc == null) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(hc.Value)); } } else { return(RedirectToAction("Index", new { msg = "登入失敗!手機號碼或密碼有誤!" })); } }
public HttpResponseMessage Login([FromBody] Models.LoginInfo LoginInfo) { Models.UserSession UserManager = new Models.UserSession(); string msg = string.Empty; var userSession = new Models.UserSession().Login(LoginInfo.UserName, LoginInfo.Password, out msg); if (string.IsNullOrWhiteSpace(msg)) { if (!string.IsNullOrWhiteSpace(LoginInfo.IMEI)) { userSession.LOGFLAG = LoginInfo.IMEI; } userSession.LASTLOGINTIME = DateTime.Now; userSession.Version = LoginInfo.Version; userSession.Plateform = LoginInfo.Plateform; userSession.ChannelID = LoginInfo.ChannelID; UserManager.SetUserSession(userSession); resObj.data = userSession; } else { resObj.error = 1; resObj.data = msg; } return(Json(resObj)); }
public JsonResult UpdateLoginInfo(int id, string name, string newPwd, string currentPwd) { TblLoginInfo tblLoginInfo = new TblLoginInfo(); string currentEncrypte = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(currentPwd))); string dbEncrypte = tblLoginInfo.GetAll().OrderBy(a => a.ID).FirstOrDefault().Password.ToString(); if (currentEncrypte == dbEncrypte) { string newPwdEncrypte = tblLoginInfo.EncryptSha(tblLoginInfo.EncryptMd5(HttpUtility.UrlDecode(newPwd))); Models.LoginInfo loginInfo = new Models.LoginInfo() { ID = id, UserName = HttpUtility.UrlDecode(name), Password = newPwdEncrypte, TransactionDate = DateTime.Now.ToString() }; tblLoginInfo.Update(loginInfo); return GetLoginInfo(); } else { return GetLoginInfo(false); } }
public ActionResult AdminValidLoginProcess(Models.LoginInfo li) { if (li.Phone == null) { return(RedirectToAction("AdminIndex", new { msg = "請輸入帳號" })); } if (li.PW == null) { return(RedirectToAction("AdminIndex", new { msg = "請輸入密碼" })); } DB.DB mydb = new DB.DB(); DB.IAdmin ia = new DB.Impl_Admin(mydb.Connection); if (ia.CheckLogin(li.Phone, li.PW)) { Session.Add("Login", li.Phone); Session.Add("LoginType", "a"); HttpCookie hc = Request.Cookies["ReUrl"]; if (hc == null) { return(RedirectToAction("Index", "Home")); } else { return(Redirect(hc.Value)); } } else { return(RedirectToAction("AdminIndex", new { msg = "登入失敗!帳號或密碼有誤!" })); } }
public ActionResult Login(Models.LoginInfo loginInfo) { if (Session["userToken"] != null) { return(RedirectToAction("Index")); } if (String.IsNullOrEmpty(loginInfo.username) || String.IsNullOrEmpty(loginInfo.password)) { ViewBag.ErrorMessage = "Please provide username & password"; return(RedirectToAction("Login")); } try { string userToken = serviceRef.LoginWithAD(loginInfo.username, loginInfo.password); Session["userToken"] = userToken; return(RedirectToAction("Index")); } catch (FaultException <ServiceReference1.ServiceFault> fault) { ViewBag.ErrorMessage = fault.Detail.Message; return(View()); } }
public ActionResult Login(Models.LoginInfo daxLogin) { using (DaxiomaticWebPage.EntityFrameWork.villadsenwp_dk_dbEntities myDB = new EntityFrameWork.villadsenwp_dk_dbEntities()) { var usr = myDB.DaxLoginInfo.Where(u => u.Username == daxLogin.UserName && u.Password == daxLogin.PassWord).FirstOrDefault(); if (usr.UserLevel == 0) { SessionData.SessionProp = usr.ID; Session["ID"] = usr.ID; Session["UserName"] = usr.Username.ToString(); return(RedirectToAction("StatisticsUserIndex", "UserStatistics")); } else if (usr.UserLevel == 1) { SessionData.SessionProp = usr.ID; Session["UserName"] = usr.Username.ToString(); return(RedirectToAction("AdminStatisticIndex", "AdminStatistic")); } else if (usr != null) { ModelState.AddModelError("", "UserName or PassWord is not valid"); } } return(View()); }
public ActionResult ValidLoginProcess(Models.LoginInfo li) { List <String> accts = new List <string>(); List <String> pwd = new List <string>(); List <String> name = new List <string>(); accts.Add("mark"); pwd.Add("abcd1234"); name.Add("Ming"); for (int i = 0; i <= accts.Count - 1; i++) { if (li.Acct == accts[i]) { if (li.Pass == pwd[i]) { Session.Add("UserName", name[i]); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", new { errorMsg = "lf" })); } } } return(View()); }
public JsonResult GetLoginInfo() { TblLoginInfo tblLoginInfo = new TblLoginInfo(); Models.LoginInfo lgIn = new Models.LoginInfo() { ID = tblLoginInfo.GetAll().OrderByDescending(i => i.ID).FirstOrDefault().ID, UserName = tblLoginInfo.GetAll().OrderByDescending(i => i.UserName).FirstOrDefault().UserName }; object loginInfo = lgIn; return Json(loginInfo, JsonRequestBehavior.AllowGet); }
public ActionResult ValidLoginProcess(Models.LoginInfo li) { bool blnLogin = false; PubClass myClass = new PubClass(); blnLogin = myClass.IsLoginSuccessed(li.Acct); if (blnLogin) { DataTable dtUserInfo = myClass.dtReturn; DataRow drRowUserInfo = dtUserInfo.Rows[0]; Models.UserInfo userInfo = new Models.UserInfo(); userInfo.userName = drRowUserInfo["userName"].ToString(); userInfo.phoneNumber = drRowUserInfo["phoneNumber"].ToString(); userInfo.job = drRowUserInfo["job"].ToString(); userInfo.jobIntroduction = drRowUserInfo["jobIntroduction"].ToString(); userInfo.imgPath = drRowUserInfo["imgPath"].ToString(); //HttpCookie Cookie = new HttpCookie("LoginName", userInfo.userName); //HttpContext.Response.Cookies.Add(Cookie); Session.Add("LoginName", li.Acct); TempData["userInfo"] = userInfo; return(RedirectToAction("Chat", "Home")); //取出User電腦上是否有原有要瀏覽的網頁,因為未登入而前來登入 //HttpCookie cc = Request.Cookies["ReUrl"]; //if (cc == null) //{ // //return RedirectToAction("Main", "Member"); // return RedirectToAction("LoginSuccess"); //} //else //{ // return RedirectToAction("chat","home",new { ui = userInfo }); //} } else { return(RedirectToAction("Index", new { tp = "lf" })); } }
public void Login() { //invalid prof login Models.LoginInfo login = new Models.LoginInfo(); login.User = Models.UserType.Professor; login.Username = "******"; login.Password = "******"; HomeController controller = new HomeController(); RedirectToRouteResult result = controller.Login(login) as RedirectToRouteResult; Assert.IsTrue(result.RouteValues["action"] == "Login" && result.RouteValues["controller"] == "Home"); //valid prof login login = new Models.LoginInfo(); login.User = Models.UserType.Professor; login.Username = "******"; login.Password = "******"; controller = new HomeController(); RedirectToRouteResult result2 = controller.Login(login) as RedirectToRouteResult; Assert.IsTrue(result2.RouteValues["action"] == "Index" && result2.RouteValues["controller"] == "Professor"); //invalid TA login login = new Models.LoginInfo(); login.User = Models.UserType.TA; login.Username = "******"; login.Password = "******"; controller = new HomeController(); RedirectToRouteResult result3 = controller.Login(login) as RedirectToRouteResult; Assert.IsTrue(result3.RouteValues["action"] == "Login" && result3.RouteValues["controller"] == "Home"); //valid TA login login = new Models.LoginInfo(); login.User = Models.UserType.TA; login.Username = "******"; login.Password = "******"; controller = new HomeController(); RedirectToRouteResult result4 = controller.Login(login) as RedirectToRouteResult; Assert.IsTrue(result4.RouteValues["action"] == "Index" && result4.RouteValues["controller"] == "TA"); }
public async Task <ActionResult> Login([FromBody] Models.LoginInfo loginInfo) { (bool isSuccess, Resp result) = await Domain.Administrators.Account.Login(loginInfo); if (!isSuccess) { return(Pack(result)); } Claim[] claims = new Claim[] { // token new Claim(ClaimTypes.Authentication, result.Data.Token.ToString()), // 人员 ID new Claim(ClaimTypes.PrimarySid, result.Data.Id.ToString()) }; string jwt = Auth.JWT.CreateJwtToken(claims); Response.Cookies.Append(Defaults.ADMIN_AUTH_COOKIE_KEY, jwt); return(Pack(result)); }
public ActionResult Login(Models.LoginInfo info) { Post("Account/Login", info); return(Wait()); }
public ActionResult Login(Models.LoginInfo info) { Post("Account/Login", info); return(RedirectToAction("Index")); }