private void button1_Click(object sender, EventArgs e) { LoginBll lb = new LoginBll(); string name = tb_username.Text; string pwd = tb_password.Text; int i = lb.Login(name, pwd); if (i == 0) { MessageBox.Show("用户名或密码不正确!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (i == 1) { FormMain fm = new FormMain(); fm.Show(); this.Hide(); } else if (i == 2) { MessageBox.Show("用户名不能为空!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } else if (i == 3) { MessageBox.Show("密码不能为空!", "登录失败", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } }
protected void lbLogar_Click(object sender, EventArgs e) { try { User usuario = new User(); LoginBll loginBll = new LoginBll(); usuario = loginBll.autentication(txtUsuario.Text.ToLower(), txtSenha.Text); Session["nomeAssociado"] = usuario.nomeAssociado; Session["usuario"] = usuario.usuario; Session["perfil"] = usuario.perfil; Session["email"] = usuario.email; Session["centroResultado"] = usuario.centroResultado; Session["CPF"] = usuario.CPF; AcessHistoricBll acessHistoricBll = new AcessHistoricBll(); AcessHistoric acessHistoric = new AcessHistoric(); acessHistoric.perfil = usuario.perfil; acessHistoric.tipo_usuario = usuario.tipo_usuario; acessHistoric.usuario = txtUsuario.Text; acessHistoricBll.insereHistoricoAcesso(acessHistoric); Response.RedirectToRoute("REDIRECT_HOME"); } catch (Exception ex) { Utility.Alertbootsrap(ex.Message, this, UpdatePanelLogin); } }
public ActionResult LogIn(LoginViewModel userLogin) { Session["HasUser"] = false; if (ModelState.IsValid) { LoginBll bll = new LoginBll(); User user = new User(); user.UserName = userLogin.UserName; user.PassWord = userLogin.PassWord; User isValiduser = bll.IsValid(user); if (isValiduser != null) { Session["HasUser"] = true; Session["UserId"] = isValiduser.Id; Session["UserName"] = userLogin.UserName; return(RedirectToAction("Index", "UserManage")); } else { ModelState.AddModelError("CredentialError", "Invalid EmployeeName or PassWord"); userLogin.ErrorMsg = "用户名或密码错误"; return(View(userLogin)); } } else { userLogin.ErrorMsg = "模型未通过验证"; return(View(userLogin)); } }
public string AddGroupUser(string strParams) { string strError; RequestModelString reqinfo = ServerHlper.GetRequestModelString(System.Reflection.MethodBase.GetCurrentMethod().Name, strParams, out strError); if (reqinfo == null) { return(strError); } if (!LoginBll.CheckLoginId(reqinfo.TockId)) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginInfoError)); } GroupUser mod = JsonStrObjConver.JsonStr2Obj(reqinfo.Info, typeof(GroupUser)) as GroupUser; if (mod == null) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError)); } if (GroupUserBll.IsNameExist(mod.Name)) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineBll.NameExist)); } bool result = GroupUserBll.AddUser(ref mod, out strError); return(ServerHlper.MakeInfoByStatus(result, strError)); }
/// <summary> /// 返回编辑页部分视图 /// </summary> /// <param name="id">用户Id</param> /// <returns>部分视图</returns> public ActionResult UserDetail(int id = 0) { UserFormViewModel userForm = new UserFormViewModel(); if (id != 0) { UserBll bll = new UserBll(); User user = bll.GetUserById(id); if (user != null) { userForm.UserName = user.UserName; userForm.Age = user.Age; userForm.Email = user.Email; userForm.PassWord = user.PassWord; userForm.Sex = user.Sex; userForm.Status = user.Status; userForm.Id = user.Id; LoginBll loginBll = new LoginBll(); string pass = loginBll.UnBase64(user.PassWord); userForm.PassWord = pass; userForm.RealName = user.RealName; userForm.MobilePhone = user.MobilePhone; } else { return(PartialView("CreatAndEdit", userForm)); } } return(PartialView("CreatAndEdit", userForm)); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; string msg = ""; try { LoginBll lb = new LoginBll(); bool flag = false; User um = new User(); um.Uname = username; um.Upassword = password; flag = lb.loginSys(username, password); if (flag == true) { context.Session["username"] = um.Uname;//保存UserNum msg = "1"; } else { msg = "0"; } } catch { msg = "88"; } context.Response.Write(msg); }
public string OrgLogin(string strJsonParam) { RequestModelString reqinfo = JsonStrObjConver.JsonStr2Obj(strJsonParam, typeof(RequestModelString)) as RequestModelString; if (reqinfo == null) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError)); } LoginNamePassModel mod = JsonStrObjConver.JsonStr2Obj(reqinfo.Info, typeof(LoginNamePassModel)) as LoginNamePassModel; if (reqinfo == null) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError)); } OrgLoginedUserModel userInfo = LoginBll.OrgLogin(mod.UserName, mod.Password); if (userInfo != null) { JsonResutlModelString result = new JsonResutlModelString() { ErrorDesc = "success", Info = JsonStrObjConver.Obj2JsonStr(userInfo, typeof(OrgLoginedUserModel)), Status = true, StatusInt = 1 }; return(JsonStrObjConver.Obj2JsonStr(result, typeof(JsonResutlModelString))); } return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.LoginNameOrPassword)); }
protected override void Initialize(HttpControllerContext controllerContext) { //初始化请求上下文 base.Initialize(controllerContext); try { new SortedDictionary <string, string>(); string username = string.Empty; HttpRequestHeaders headers = controllerContext.Request.Headers; if (headers.Contains("e")) { text = (headers.GetValues("e").FirstOrDefault <string>().ToString() ?? string.Empty); text = System.Web.HttpUtility.UrlDecode(username); } UserInfoEntity userInfo = new LoginBll().GetUserInfo(username); this.loginid = userInfo.LoginID; this.loginname = userInfo.LoginName; List <UserAuthorityEntity> tempList = userInfo.UserRole.UserAuthority; //不存在安全问题 后续文章有权限验证 if (tempList.Where(c => c.AuthorityName == "权限名称").ToList().Count > 0) { //调用一个有权限的bll层 this.baseBll = new SeniorBll(); } else { //调用一个没有权限的bll层 this.baseBll = new OrdinaryBll(); } } catch (Exception ex) { LogHelper.WriteErrorLog("Initialize", ex); } }
public bool loginCheck(LoginBll l) { //Create a boolean variable and set its value to false and return it bool isSuccess = false; try { using (BuddyBillerRepository db = new BuddyBillerRepository()) { var usercontext = from user in db.Users where user.username.Equals(l.Username) && user.password.Equals(l.Password) && user.user_type.Equals(l.UserType) select user; if (usercontext.Any()) { //Login Sucessful isSuccess = true; } } // //SQL Query to check login //string sql = "SELECT * FROM tbl_users WHERE username=@username AND password=@password AND user_type=@user_type"; ////Creating SQL Command to pass value //SqlCommand cmd = new SqlCommand(sql, conn); ////cmd.Parameters.AddWithValue("@username", l.username); ////cmd.Parameters.AddWithValue("@password", l.password); ////cmd.Parameters.AddWithValue("@user_type", l.user_type); //SqlDataAdapter adapter = new SqlDataAdapter(cmd); //DataTable dt = new DataTable(); //adapter.Fill(dt); ////Checking The rows in DataTable //if(dt.Rows.Count>0) //{ // //Login Sucessful // isSuccess = true; //} //else //{ // //Login Failed // isSuccess = false; //} } catch (Exception ex) { MessageBox.Show(ex.Message); } return(isSuccess); }
public ActionResult CreateLogin(FormCollection form) { try { string username = form.Get("username"); string password = form.Get("password"); string type = form.Get("ddlLoginMode"); bool isFederation = type.ToLower() != "group"; LoginBll objLoginBll = new LoginBll(); ResultDto objResultDto = objLoginBll.ValidateLogin(username, password); if (objResultDto.ObjectId > 0) { UserInfo = new MasterService().GetLoginMasterInfo(objResultDto.ObjectId, isFederation); return(Json(new { message = objResultDto.Message, isSueecess = true })); } else { return(Json(new { message = objResultDto.Message, isSueecess = false })); } } catch (Exception ex) { throw ex; } }
public void TestGetValidateCode() { string url = @"C:\Train\Code"; var train = new LoginBll(); //var code = train.GetValidateCode(url); //Assert.AreEqual(true, code.Item1); }
//public static bool signin(userReg user, DBPlayer db) //{ // bool status = false; // try // { // db.AddParameters("@UserId", user.id); // db.AddParameters("@Password", user.pass); // int res = db.ExecuteNonQuery("Login", true); // if (res == 1) // { // status = true; // } // return status; // } // catch (Exception) // { // throw; // } //} public static LoginBll GetUserById(string UserId, LumexDBPlayer db) { DataTable dt; LoginBll logbal = new LoginBll(); try { db.AddParameters("@UserId", UserId); dt = db.ExecuteDataTable("[GET_USER_BY_ID_AT_LOGIN]", true); DataTableReader dr = dt.CreateDataReader(); if (dr.Read()) { logbal.UserId = dr["UserId"].ToString(); logbal.UserName = dr["UserName"].ToString(); logbal.UserGroup = dr["UserGroupId"].ToString(); logbal.PerPhoto = dr["PerPhoto"].ToString(); logbal.LastName = dr["LastName"].ToString(); logbal.IsActive = dr["IsActive"].ToString(); logbal.IsVarified = dr["isVarified"].ToString(); } else { logbal = null; } } catch (Exception) { throw; } return(logbal); }
protected void Button1_Click(object sender, EventArgs e) { CommDevLoginedUserModel mod = LoginBll.CommDevLogin(0, TextBox1.Text, TextBox2.Text); if (mod != null) { } }
public FrmCode() { LoginBll train = new LoginBll(); train.PostConfLogin(); train.GetLoginBanner(); train.PostUamtkStatic(); InitializeComponent(); LoadEvents(); }
// POST: api/Login public HttpResponseMessage Login(userLogin value) { var login = LoginBll.getLogin(value); var json = Newtonsoft.Json.JsonConvert.SerializeObject(login); HttpResponseMessage result = new HttpResponseMessage { Content = new StringContent(json, Encoding.GetEncoding("UTF-8"), "application/json") }; //这里是去掉反斜杠再放回出去,json就只剩下双引号。 return(result); }
public void checkuserid() { int expected, actual; expected = 3; LoginBll loginbll = new LoginBll(); loginbll.Username = "******"; actual = loginbll.selectID(); Assert.AreEqual(expected, actual); }
public void RecheckLogin() { expected = true; LoginBll bll = new LoginBll(); bll.Username = "******"; bll.UPassword = "******"; actual = bll.check(); Assert.AreEqual(expected, actual); }
public WelcomeModule() { #region LoginRemote Get["/"] = _ => { return(View["Login"]); }; Get["Login"] = _ => { //生成CSRF token. this.CreateNewCsrfToken(); return(View["Login"]); }; Post["Login"] = p => { //CSRF token 检验 this.ValidateCsrfToken(); var loginModel = this.Bind <LoginModel>(); var model = LoginBll.Verify(UserBll.GetData(), loginModel.Username, loginModel.Password); if (model != null && !string.IsNullOrEmpty(model.RoleName)) { var role = RoleBll.GetDataByName(model.RoleName); if (role != null && role.Status != "0") { Guid guid = Guid.NewGuid(); //注意 nancy的session实际用的是cookie,所以最大4K字节 Context.Request.Session[guid.ToString()] = model; return(this.LoginAndRedirect(guid, fallbackRedirectUrl: "/index")); } } return(View["Login", "false"]); }; Get["LoginOut"] = _ => { Session.DeleteAll(); return(this.LogoutAndRedirect("~/")); }; #endregion #region ClientUpdate Get["api/RequestNewestPackageUrl/{HopitalID}/{OldNumber}"] = p => { RequestNewestPackageUrlResponseModel res = ClientUpdateBll.RequestNewestPackageUrl(p.HopitalID, p.OldNumber); return(Response.AsJson(res)); }; Get["api/RequestNewestAutoupdater/{OldVersion}"] = p => { RequestNewestPackageUrlResponseModel res = ClientUpdateBll.RequestNewestAutoupdater(p.OldNumber); return(Response.AsJson(res)); }; #endregion }
public ActionResult SelectGroup() { LoginBll _loginService = new LoginBll(); string clusterName = string.Empty; var lstGroupMasterViewDto = _loginService.GetSelectGroupDetails(UserInfo.UserID, out clusterName); ViewBag.ClusterName = clusterName; return(View(lstGroupMasterViewDto)); }
public string Logout(string strJsonParam) { RequestModelString reqinfo = JsonStrObjConver.JsonStr2Obj(strJsonParam, typeof(RequestModelString)) as RequestModelString; if (reqinfo == null) { return(ServerHlper.MakeInfoByStatus(false, ConstDefineWs.HttpParamError)); } LoginBll.Logout(reqinfo.TockId); return(ServerHlper.MakeInfoByStatus(true, "success")); }
public ActionResult CheckCodePiece(int[] xy) { var result = new ResultModel(); var train = new LoginBll(); string point = train.getPoint(xy); string jsonResult; var check = train.PostCaptchaCheck(point, out jsonResult); result.code = check.result_code == 4 ? 0 : check.result_code; result.msg = check.result_message; result.data = jsonResult; return(Json(result)); }
public ActionResult Login(string username, string password) { var loginInfo = new LoginBll().Login(username, password); if (loginInfo != null && loginInfo.Id > 0) { string data = JsonConvert.SerializeObject(loginInfo); CookieHelper.SetCookie("Context_UserInfo", AESHelp.AESEncrypt(DesHelper.Encode(data, DesHelper.SECRET))); return(Redirect(ViewBag.RootNode + "/Home/Index")); } ModelState.AddModelError("error", "用户名或密码错误"); return(View()); }
private void SaveTextBoxInfo() { string loginway = checkBoxStaffnoLogin.Checked ? "usestaffnologin" : "usenamelogin"; Dictionary <string, string> tmpdict = new Dictionary <string, string> { { "LoginWay", loginway }, { "LoginName", txtBoxUserName.Text }, { "LoginIP", txtMESServerIP.Text }, { "staffno", txtStaffno.Text } }; LoginBll.SaveLoginInfo(tmpdict); }
private void btnLogin_Click(object sender, System.EventArgs e) { _user.EmpId = txtId.Text.Trim(); _user.Password = txtPwd.Text; if (LoginBll.CanLogin(_user)) { DialogResult = DialogResult.OK; } else { MsgBoxLib.ShowError("用户名/密码错误,请重试"); } }
public ActionResult Register() //用户注册2.0测试版本 { GetUserInfoDal getuserinfodal = new GetUserInfoDal(); string openid = CookieHelper.GetCookieValue("openid"); string user_id = getuserinfodal.GetUserID(openid); user user1 = new user(); user1.UserID = user_id; user1.Profession = Request["profession"]; user1.Function = Request["function"]; user1.Education = Request["education"]; user1.Field = Request["field"]; user1.Sex = Request["sex"]; user1.Selfintroduction = Request["selfintroduction"]; user1.SearchID = Guid.NewGuid().ToString("N"); user1.Success = "0"; user1.Address = Request["address"]; LoginBll login = new LoginBll(); string isregistered = login.IsRegistered(user_id, user1.Profession); int registernumber = login.RegisterNumber(user_id); if (isregistered == "yes")//注册过当前职业 { return(Content("fail")); } else { if (registernumber >= 2) { return(Content("registermax")); } else { string isregistered2 = login.IsRegistered(user_id); if (isregistered2 == "yes") { user1.UserNumber = login.GetUserNumberByUserId(user_id); } else { string number = login.GetLastNumber(); //得到最新的编号 int a = Convert.ToInt32(number) + 1; user1.UserNumber = a.ToString(); login.UpdateLastNumber(a.ToString()); //跟新最新的编号 } login.Register(user1); return(Content("ok")); } } }
public ActionResult CheckCode(string point) { var train = new LoginBll(); string jsonResult; var check = train.PostCaptchaCheck(point, out jsonResult); var result = new ResultModel() { code = check.result_code == 4 ? 0 : check.result_code, msg = check.result_message, data = check }; return(Json(result)); }
protected void btnLogin_Click(object sender, EventArgs e) { if (txtbxUserName.Text != "" && txtbxPassword.Text != "") { try { LoginBll loginbll = new LoginBll(); loginbll.UserId = txtbxUserName.Text.ToString(); loginbll.UserPass = txtbxPassword.Text.ToString(); if (loginbll.VerifyPassword()) { loginbll = loginbll.GetUserById(loginbll.UserId); if (loginbll.IsVarified == "Yes") { LumexSessionManager.Add("UserGroupId", loginbll.UserGroup); LumexSessionManager.Add("ActiveUserId", loginbll.UserId); LumexSessionManager.Add("ActiveUserName", loginbll.UserName); LumexSessionManager.Add("UserLastName", loginbll.LastName); LumexSessionManager.Add("UserAvater", loginbll.PerPhoto); LumexSessionManager.Add("isMenu", "N"); LumexSessionManager.Add("ActiveMenuFor", "globalapp"); //LumexSessionManager.Add("UserIdForView",""); Response.Redirect("~/default.aspx", false); } else { string message = " <span class='actionTopic'>" + " Your account is not Varified. Please Check your Email. Thanks" + "</span>."; MyAlertBox("var callbackOk = function () { window.location = \"/login.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", \"\");"); } } else { lblmsg.Visible = true; lblmsg.Text = "User ID or Password is invalid."; } } catch (Exception ex) { // lblmsg.Visible = true; // lblmsg.Text = ex.ToString(); } } else { lblmsg.Visible = true; lblmsg.Text = "UserName or Password field is Empty."; } }
public ActionResult PostLogin(UserInfo user) { string data = string.Empty; var result = new ResultModel(); var train = new LoginBll(); do { var check = UserCheck(user); if (check.Item1 != 0) { result.code = check.Item1; result.msg = check.Item2; break; } var login = train.PostLogin(user.loginName, user.loginPwd, out data); if (login.result_code != 0) { result.code = login.result_code; result.msg = login.result_message; result.data = data; break; } var tk = train.PostUamtk(out data); if (tk.result_code != 0) { result.code = tk.result_code; result.msg = tk.result_message; result.data = data; break; } var apptk = train.PostUamauthClient(tk.newapptk, out data); result.code = apptk.result_code; result.msg = apptk.result_message; result.data = apptk; if (apptk.result_code == 0) { result.data = new { apptkdata = apptk, confdata = train.PostConf(), InitMydata = train.PostInitMy12306() }; } } while (false); return(Json(result)); }
public string UpdateLoginTimeByUuid(string strJsonParam) { RequestModelString reqinfo = JsonStrObjConver.JsonStr2Obj(strJsonParam, typeof(RequestModelString)) as RequestModelString; if (reqinfo == null) { return(ServerHlper.MakeInfoByStatus(false, "刷新登录信息,参数不对")); } bool bRsult = true; LoginBll.UpdateLoginStatus(reqinfo.TockId); return(ServerHlper.MakeInfoByStatus(bRsult, bRsult.ToString())); }
public bool VerifyPassword(LoginBll logbal, LumexDBPlayer db) { DataTable dt;// = new DataTable(); string UserIdDb, PasswordDb; bool status = false; string UserId = logbal.UserId; // string Password = LumexLibraryManager.EncodeIntoMd5Hash(logbal.Userpass); string Password = ProtectPassword(logbal.UserPass); try { db.AddParameters("@UserId", UserId); dt = db.ExecuteDataTable("[GET_USER_PASS_ID_AT_LOGIN]", true); DataTableReader dr = dt.CreateDataReader(); if (dr.Read()) { UserIdDb = dr["UserId"].ToString(); PasswordDb = dr["Password"].ToString(); if (UserId == UserIdDb && Password == PasswordDb) { status = true; } else { status = false; } } else { logbal = null; } } catch (Exception) { throw; } finally { } return(status); }