public ActionResult Index(loginModel loginModel) { var log = LoginDao.ClientLogin(loginModel.userName, loginModel.password).ToList(); if (ModelState.IsValid) { if (log[0].email != null) { ViewData["datalogin"] = log; //add session Session["tenKH"] = log[0].tenKH; Session["email"] = log[0].email; Session["idUser"] = log[0].idUser; Session["idKH"] = log[0].idKH; Session["thongbao"] = "ok"; return(RedirectToAction("Check")); } else { Session["thongbao"] = "fail"; ViewBag.error = "Login failed"; return(RedirectToAction("Index")); } } else { return(RedirectToAction("Index")); } }
public ActionResult Index(loginModel login) { try { if (!ModelState.IsValid) { Session["login"] = "******"; ViewBag.Errores = "Login Incorrecto"; return(View()); } bool loginOK = dao.login(login.usuario, login.password); if (loginOK) { Session["login"] = "******"; return(RedirectToAction("admin")); } else { ViewBag.Errores = "Login Incorrecto"; return(View()); } } catch (Exception) { throw; } }
private async void Save_OnClickedicked(object sender, EventArgs e) { _url = " http://dev.foodforus.cloud/public/api/v1/productInterest"; var form = new FormUrlEncodedContent(new[] { new KeyValuePair <string, string>("api_key", _apiKey), new KeyValuePair <string, string>("productInterest1", ProductTypes.Text), new KeyValuePair <string, string>("productInterest2", ProductTypetwo.Text), new KeyValuePair <string, string>("productInterest3", ProductTypesthree.Text), }); _response = await _client.PostAsync(_url, form); var respond = await _response.Content.ReadAsStringAsync(); loginModel responses = JsonConvert.DeserializeObject <loginModel>(respond); UserDialogs.Instance.Alert("Notification", "Successfully updated product Alerts", "OK"); CrossLocalNotifications.Current.Show("FoodForus ", "Successfully updated product Alerts", 101, DateTime.Now.AddSeconds(5)); await Navigation.PushModalAsync(new SellersMaster()); }
public ActionResult LoginCheck(FormCollection collection) { int matching_result; loginModel loginModel = new loginModel { username = collection["username"], password = collection["password"] }; using (SqlConnection conn = new SqlConnection(cs)) { string query = "(select count(*) from login where username=@username AND password=@password)"; SqlCommand sqlCommand = new SqlCommand(query, conn); sqlCommand.Parameters.AddWithValue("@username", loginModel.username); sqlCommand.Parameters.AddWithValue("@password", loginModel.password); conn.Open(); matching_result = (int)sqlCommand.ExecuteScalar(); //Exexute scalar returns a single value,return type is object, //we can convert it at any type. } if (matching_result > 0) { return(RedirectToAction("Index", "Patient")); } else { return(View("WrongLogin")); } }
/// <summary> /// 添加 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int insert(loginModel model) { //定义添加sql string sql = "insert cc values(@name,@pwd,default)"; //集合存储值 SqlParameter[] sqlpar = new SqlParameter[] { new SqlParameter("@name", model.name), new SqlParameter("@pwd", model.pwd), }; //定义查询sql string sql2 = "select * from cc where name=@name"; //查询所需的参数 SqlParameter[] sqlpar2 = new SqlParameter[] { new SqlParameter("@name", model.name), }; int num = 0; //执行查询判断是否存在相同值 object cx = DBhelp.select(sql2, sqlpar2); if (cx != null) { //返回一个数字(任意数字即可,前台判断所用) return(num = 66); } //执行添加语句 num = DBhelp.Notquery(sql, sqlpar); return(num); }
// public ActionResult Login(loginModel model) { if (ModelState.IsValid) { var dao = new userDao(); var result = dao.Login(model.userName, encryptor.MD5Hash(model.passWord)); if (result == 1) { var user = dao.getById(model.userName); var userSession = new userLogin(); userSession.userName = user.userName; userSession.userID = user.Id; Session.Add(commonConst.user_session, userSession); return(RedirectToAction("Index", "Home")); } else if (result == -2) { ModelState.AddModelError("", "Bạn không có quyền vào trang này !"); } else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại !"); } else if (result == -1) { ModelState.AddModelError("", "Tài khoản đang bị khóa !"); } else { ModelState.AddModelError("", "Đăng nhập không đúng !"); } } return(View("Index")); }
public ActionResult Login(loginModel lm) { if (lm.lm_username == null || lm.lm_password == null) { return(View()); } var r = (from user in db.Users where user.account == lm.lm_username select user).FirstOrDefault(); if (r == null) { ViewBag.message = "帳號密碼錯誤"; } else { string SaltAndPassword = String.Concat(r.salt, lm.lm_password); string EncryptPassword = Encrypt(SaltAndPassword); if (string.Compare(EncryptPassword, r.password, false) == 0) { ViewBag.message = "登入成功"; GetTicket(lm.lm_username); return(RedirectToAction("Menu", "Restaurant")); } else { ViewBag.message = "帳號密碼錯誤"; } } return(View()); }
public ActionResult Login(loginModel model) { if (ModelState.IsValid) { BusinessLayerResult <Musteri> res = mm.LoginMusteri(model); if (res.Errors.Count > 0) { if (res.Errors.Find(x => x.Code == ErrorMessageCode.UserIsNotActive) != null) { return(RedirectToAction("AktifDegil")); } res.Errors.ForEach(x => ModelState.AddModelError("", x.Message)); return(View(model)); } else { Session["login"] = res.result; return(RedirectToAction("Index")); } } return(View(model)); }
public ActionResult login(loginModel modal) { if (ModelState.IsValid) { IEnumerable <user> ab = (from r in db.users where r.uEmail == modal.UserEmail && r.uPassword == modal.Password && r.uActivAdmin == true && r.uActivation == true select r).ToList(); string userNam = ""; if (ab.Count() > 0) { foreach (var item in ab) { int userid = item.userID; userNam = item.userName; HttpContext.Session["UserID"] = userid; HttpContext.Session["userNam"] = userNam; //string base64 = Convert.ToBase64String(item.AgentLogo); //Session["image"] = base64; } if (Convert.ToInt16(Session["UserID"]) == 2) { return(RedirectToAction("Dashboard")); } return(RedirectToAction("New")); //System.Web.Security.FormsAuthentication.SetAuthCookie(userNam, true); //User.Identity.Name } else { ViewBag.Error = "Invalid Credentials or Your Account is suspended by Admin"; } } return(View()); }
public async Task <IActionResult> Login(loginModel model) { if (ModelState.IsValid) { var result = await signInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, false); if (result.Succeeded) { if (!string.IsNullOrEmpty(model.ReturnUrl) && Url.IsLocalUrl(model.ReturnUrl)) { return(Redirect(model.ReturnUrl)); } else { return(RedirectToAction("Index", "Home")); } } else { ModelState.AddModelError("", "არასწორი სახელი ან პაროლი"); } } return(View(model)); }
public int Post(loginModel loginModel) { int id; try { loginDB loginEF = new loginDB() { userName = loginModel.userName, pswrd = loginModel.password, }; // will save data here in database; using (BGEnqiryEntities context = new BGEnqiryEntities()) { //context.homes.Add(loginEF); context.loginDBs.Add(loginEF); context.SaveChanges(); id = loginEF.id; } return(id); } catch (Exception ex) { return(-1); } }
private void GetData() { //设置ID userBll bll = new userBll(); login = bll.GetByID(Convert.ToInt32(Request["id"])); }
public object Login([FromBody] loginModel value) { try { var userData = _context.Users.Where(x => x.Email == value.email).FirstOrDefault(); if (userData != null) { var productCount = _context.ProductCart.Where(x => x.UserId == userData.UserId).Select(x => x.ProductCount).ToList().Sum(); var returnUser = new loginModel { UId = userData.UserId, email = userData.Email, fullName = userData.FullName, photoUrl = userData.PhotoUrl, cartCount = productCount }; return(returnUser); } else { var user = new Users { Email = value.email, FullName = value.fullName, FName = value.fName, LName = value.lName, PhotoUrl = value.photoUrl, MobileNo = null }; _context.Users.Add(user); _context.SaveChanges(); var newUserId = _context.Users.Where(x => x.Email == value.email).Select(x => x.UserId).FirstOrDefault(); var productCart = new ProductCart { UserId = newUserId, ProductCount = 0, CartProductId = "0" }; _context.ProductCart.Add(productCart); _context.SaveChanges(); var returnUser = new loginModel { UId = newUserId, email = value.email, fullName = value.fullName, photoUrl = value.photoUrl, cartCount = 0 }; return(returnUser); } } catch (DbUpdateConcurrencyException) { throw; } }
/// <summary> /// 根据ID进行查询 /// </summary> /// <param name="id"></param> /// <returns></returns> public static loginModel selectID(int id) { //创建连接字符串 string sql = "select * from cc where id=@id"; //创建sqlpar SqlParameter[] sqlpar = new SqlParameter[] { new SqlParameter("@id", id) }; //方法调用 SqlDataReader sdr = DBhelp.slelect(sql, sqlpar); //新建MODEL 存储值 loginModel model = new loginModel(); //判断sqldatareader是否存在数据 if (sdr.HasRows) { ///遍历下一条 while (sdr.Read()) { //循环存储进入model model.id = Convert.ToInt32(sdr["id"]); model.name = sdr["name"].ToString(); model.pwd = sdr["pow"].ToString(); } } //返回一个model类型的值 return(model); }
public ActionResult Login(loginModel o) { if (o.userName != null) { return(View("Index")); } return(View()); }
public LoginViewModel() { LoginData = new loginModel(); ResponseloginData = new loginModel(); LoadLoginCommand = new Command(async async => await LoginDataCommand()); validateNameCommand = new Command(namevalidate); validatePasswordCommand = new Command(passwordvalidate); }
public static async Task <bool> LoginUser( string email, string password, string uri) { var client = new HttpClient(); var responseModel = new loginModel(); var model = new loginModel { Email = email, Password = password, }; var json = JsonConvert.SerializeObject(model); HttpContent httpContent = new StringContent(json); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync( uri, httpContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content == "[]\n") { var res = await Application.Current.MainPage.DisplayAlert("Error", "Incorect username or password", "Ok", "Cancel"); if (res) { return(false); } else { return(false); } } else { Console.WriteLine(content); responseModel = JsonConvert.DeserializeObject <loginModel>(content); Preferences.Set("id", responseModel.Id); Application.Current.Properties["id"] = responseModel.Id; Application.Current.Properties["name"] = responseModel.Email; Application.Current.Properties["password"] = responseModel.Password; } /* Console.WriteLine(Application.Current.Properties["id"]);*/ return(true); } return(false); }
public ActionResult login(loginModel lg) { using (BPOContext bpe = new BPOContext()) { if (bpe.Admin.Any(x => x.AdminId == lg.username && x.Password == lg.password)) { FormsAuthentication.SetAuthCookie(lg.username, false); } } return(RedirectToAction("Index", "Admin")); }
public bool ValidateLogin(loginModel _loginModel) { if (_loginModel.username == "Akhilesh" && _loginModel.password == "Akhilesh@123") { return(true); } else { return(false); } }
public ActionResult Login(string returnUrl, string msgGoogle = "") { loginModel account = new loginModel(); ViewBag.RetunUrl = returnUrl; if (msgGoogle != string.Empty) { ViewBag.ModelStateCount = 1; } ViewData["msgGoogle"] = msgGoogle; return(View(account)); }
//public List<loginModel> GetLogin() //{ // ///uses read procedure by user ID and returns corresponding values // DbCommand get_Login = db.GetStoredProcCommand("sp_selectct2User"); // db.AddInParameter(get_Login, "@userID", DbType.Int32); // DataSet ds = db.ExecuteDataSet(get_Login); // var userLogin = (from drRow in ds.Tables[0].AsEnumerable() // select new loginModel() // { // emailAddress = drRow.Field<string>("emailAddress"), // userPassword = drRow.Field<string>("userPassword"), // }).ToList(); // return userLogin; //} public userModel GetLogin(loginModel login) { userModel currentUser = new userModel(); ///uses read procedure by login properties and returns corresponding user DbCommand get_Login = db.GetStoredProcCommand("sp_readct2LoginUser"); db.AddInParameter(get_Login, "@emailAddress", SqlDbType.VarChar, login.emailAddress); db.AddInParameter(get_Login, "@userPassword", SqlDbType.VarChar, login.userPassword); DataSet ds = db.ExecuteDataSet(get_Login); return(currentUser); }
public ActionResult Login(loginModel loginCredentials) { // ////create an instance of the user userModel currentUser = new userModel(); // ////create instance of userDataController ct2UserDataController userDataController = new ct2UserDataController(""); // ////send login credentials to userDataController and set returned user to our current instance currentUser = userDataController.GetLogin(loginCredentials); // ////call LoggedIn return(LoggedIn(currentUser)); }
public IActionResult Login([Bind] loginModel login) { if (!string.IsNullOrEmpty(login.name) && !string.IsNullOrEmpty(login.password) && string.IsNullOrEmpty(login.type)) { return(RedirectToAction("Login")); } //Check the user name and password //Here can be implemented checking logic from the database ClaimsIdentity identity = null; bool isAuthenticated = false; if (login.type == "User" && login.name.ToUpper().Trim() == "ADMIN" && login.password == "1234") { //Create the identity for the user identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, login.name), new Claim(ClaimTypes.Role, "Admin") }, CookieAuthenticationDefaults.AuthenticationScheme); isAuthenticated = true; } else if (obj_customer.getAllCustomer().Any(x => x.custid.ToUpper().Trim() == login.name.ToUpper().Trim()) && login.password == "12345") { //Create the identity for the user identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, login.name), new Claim(ClaimTypes.Role, "Customer") }, CookieAuthenticationDefaults.AuthenticationScheme); isAuthenticated = true; } if (isAuthenticated) { var principal = new ClaimsPrincipal(identity); var logi = HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal); if (login.type == "User") { return(RedirectToAction("Index", "customer")); } else { return(RedirectToAction("Index", "purchase")); } } ModelState.AddModelError("validatetion", "Invalid credential"); return(View()); }
public static async Task <bool> UpdateUser( int id, string email, string password, string uri) { var client = new HttpClient(); var responseModel = new loginModel(); var model = new loginModel { Id = id, Email = email, Password = password, }; var json = JsonConvert.SerializeObject(model); HttpContent httpContent = new StringContent(json); httpContent.Headers.ContentType = new MediaTypeHeaderValue("application/json"); var response = await client.PostAsync( uri, httpContent); if (response.IsSuccessStatusCode) { string content = await response.Content.ReadAsStringAsync(); if (content == "[]\n") { var res = await Application.Current.MainPage.DisplayAlert("Error", "Try again", "Ok", "Cancel"); if (res) { return(false); } else { return(false); } } else { Console.WriteLine(content); } /* Console.WriteLine(Application.Current.Properties["id"]);*/ return(true); } return(false); }
public IHttpActionResult login(loginModel loginModel) { bool successfulLogin = GetLogin(loginModel.UserName, loginModel.Password); if (successfulLogin) { return(Ok()); } else { return(Ok("UserName or Password Does Not Exist")); } }
public void AddLoginTest() { // Arrange var controller = new HomeController(); loginModel loginModeldetail = new loginModel { UserName = "******", UserId = 1, Password = "******" }; var response = controller.login(loginModeldetail) as OkResult; Assert.IsNotNull(response, "User unable to log in with correct login info"); }
/// <summary> /// 删除 /// </summary> /// <param name="model"></param> /// <returns></returns> public static int delete(loginModel model) { //定义sql string sql = "update cc set zt=1 where id=@id"; //修改所需的参数 SqlParameter[] sqlpar = new SqlParameter[] { new SqlParameter("@id", model.id), }; //执行 int num = DBhelp.Notquery(sql, sqlpar); return(num); }
public IActionResult Login([FromBody] loginModel model) { string message = "Email Adresi hatalı veya kayıtlı değil"; if (string.IsNullOrEmpty(model.email)) { return(BadRequest("Kullanıcı Adı Boş Bırakılamaz")); } if (string.IsNullOrEmpty(model.password)) { return(BadRequest("Parola Boş Bırakılamaz")); } var account = _db.Set <Account>().FirstOrDefault(x => x.Email == model.email); if (account == null) { return(BadRequest(message)); } if ((bool)!account.isActive) { return(BadRequest("Hesap Aktif Değil. Aktif Etmek için Tıklayınız")); } var password = _db.Set <UserPassword>().FirstOrDefault(x => x.UserId == account.Id && x.Password == model.password); if (password == null) { return(BadRequest("Parola Hatalı")); } if (!password.ActivePassword) { return(BadRequest("Eski Kullandığınız parolayı girdiniz. Lütfen Güncel parolanızı giriniz.")); } var tokenString = GenerateJSONWebToken(model); var loginApi = new LoginApiModel { id = account.Id, name = account.Name, surname = account.Surname, token = tokenString, role = account.Role }; return(Json(loginApi)); }
/// <summary> /// 点击注册 /// </summary> private void Registere(string Content) { try { _timerWtLogin.Stop(); TimerLoad(); Hander = Content; TemplateType = Content.Equals("注册") ? "RegisteredDataTemplate" : "ResetDataTemplate"; //LoginCollection = new loginModel(); RestCollection = new loginModel(); } catch (Exception ex) { Msg.Error(ex); } }
public async Task <IActionResult> AuthUser(loginModel loginModel) { var userModel = await _context.User.Include(user => user.addressModel).SingleOrDefaultAsync(e => e.email == loginModel.email); if (userModel == null) { return(Content("BAD_LOGIN")); } if (userModel.password != loginModel.password) { return(Content("BAD_LOGIN")); } return(Ok(userModel)); }