public HttpResponseMessage Login([FromBody] UserHelp value) { if (ModelState.IsValid) { User user = LogicUsers.GetAllUsers().FirstOrDefault(p => p.UserName == value.UserName && p.Password == value.Password); return((user != null) ? new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <User>(user, new JsonMediaTypeFormatter()) }: new HttpResponseMessage(HttpStatusCode.OK) { Content = new ObjectContent <String>("You aren't singed", new JsonMediaTypeFormatter()) }); } List <string> ErrorList = new List <string>(); //if the code reached this part - the user is not valid foreach (var item in ModelState.Values) { foreach (var err in item.Errors) { ErrorList.Add(err.ErrorMessage); } } return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new ObjectContent <List <string> >(ErrorList, new JsonMediaTypeFormatter()) }); }
private void button1_Click(object sender, EventArgs e) { string uname = user_name.Text.ToString(); string passw = pwd.Text.ToString(); string repassw = repwd.Text.ToString(); if (uname.Equals("") || passw.Equals("") || repwd.Equals("")) { MessageBox.Show("请完善信息!"); } else { if (!passw.Equals(repassw)) { MessageBox.Show("两次密码不同"); } else { if (UserHelp.Insert_uinfo(uname, passw)) { MessageBox.Show("录入成功!您申请的账号为:" + UserHelp.Get_num(uname, passw)); this.Close(); } else { MessageBox.Show("录入失败!"); } } } }
private void button1_Click(object sender, EventArgs e) { string p1 = new_password.Text.ToString().Trim(); string p2 = makesure_new_password.Text.ToString().Trim(); if (p1.Equals("") || p2.Equals("")) { MessageBox.Show("密码不能为空!"); } else { if (!p1.Equals(p2)) { MessageBox.Show("两次密码必须相同!"); } else { if (UserHelp.Change_pwd(UserHelp.uid, p1)) { MessageBox.Show("修改密码成功!"); } else { MessageBox.Show("修改密码失败!"); } } } }
private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { limit = "0"; } else if (radioButton2.Checked == true) { limit = "1"; } else { limit = "2"; } if (UserHelp.Change_info(uid, pwd.Text.ToString(), limit)) { MessageBox.Show("修改成功!"); Init_view(); } else { MessageBox.Show("修改失败!"); } }
private void button1_Click(object sender, EventArgs e) { string uid = textBox1.Text.ToString(); string pwd = textBox2.Text.ToString(); string limit = ""; if (uid.Equals("") && pwd.Equals("")) { MessageBox.Show("账号密码不能为空!"); } else if (uid.Equals("")) { MessageBox.Show("账号不能为空!"); } else if (pwd.Equals("")) { MessageBox.Show("密码不能为空!"); } else { switch (comboBox1.SelectedItem.ToString().Trim()) { case "普通员工": limit = "0"; break; case "高级工程师": limit = "1"; break; case "系统管理员": limit = "2"; break; default: MessageBox.Show("身份选择异常!"); break; } if (!limit.Equals("")) { if (UserHelp.User_Login(uid, pwd, limit)) { UserHelp.Set_uid(uid); Form form = new FormMain(limit); form.Show(); this.Hide(); } else { MessageBox.Show("密码错误!"); } } } }
private void button3_Click(object sender, EventArgs e) { if (UserHelp.Delete_info(uid)) { MessageBox.Show("删除成功!"); Init_view(); } else { MessageBox.Show("删除失败!"); } }
void Start() { mouseController = new MouseController(); observer = new Observer(); boyObject = GameObject.Find("Boy"); Boy boy = boyObject.AddComponent <Boy>(); userHelpObject = GameObject.Find("UserHelp"); UserHelp userHelp = userHelpObject.AddComponent <UserHelp>(); observer.addMouseEventsReceiver(boy); observer.addMouseEventsReceiver(userHelp); mouseController.addObserver(observer); }
public IActionResult Login(UserHelp userHelp) { var userFromRepo = repos.Login(userHelp.Username.ToLower(), userHelp.Password); if (userFromRepo == null) { return(Unauthorized()); } var claims = new[] { new Claim(ClaimTypes.NameIdentifier, userFromRepo.Id.ToString()), new Claim(ClaimTypes.Name, userFromRepo.UserName), new Claim(ClaimTypes.GivenName, userFromRepo.Name), new Claim(ClaimTypes.Role, userFromRepo.Type), new Claim(ClaimTypes.Surname, userFromRepo.LastName), new Claim(ClaimTypes.MobilePhone, userFromRepo.PhoneNumber), new Claim(ClaimTypes.StateOrProvince, userFromRepo.City) }; var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(configs.GetSection("AppSettings:Token").Value)); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha512Signature); var tokenDescriptor = new SecurityTokenDescriptor { Subject = new ClaimsIdentity(claims), Expires = DateTime.Now.AddDays(10), SigningCredentials = creds }; var tokenHandler = new JwtSecurityTokenHandler(); var token = tokenHandler.CreateToken(tokenDescriptor); return(Ok(new { token = tokenHandler.WriteToken(token) })); }
private void Init_view() { Manage_view.DataSource = UserHelp.Get_userable(); }
private void Control_HelpButtonClicked(object sender, CancelEventArgs e) { uh = new UserHelp(); uh.Show(); }