/// <summary> /// 新增用户 /// </summary> /// <param name="name"></param> private static void DoAddUser(List <string> command) { if (command.Count < 2) { Console.WriteLine("请输入动作:"); Console.WriteLine("show=显示用户的json(user show name)"); Console.WriteLine("add=新增用户,是否多IP(user add name 1)"); Console.WriteLine("renew=刷新用户安全码,重新设置是否多IP(user renew name 1)"); return; } string action = command[1]; if (command.Count < 3) { Console.WriteLine("请输入用户名"); return; } string name = command[2]; FWUser user = null; if (string.Equals(action, "show", StringComparison.CurrentCultureIgnoreCase)) { user = _userMan.GetUser(name); if (user == null) { Console.WriteLine("找不到用户:" + name); return; } } else if (string.Equals(action, "add", StringComparison.CurrentCultureIgnoreCase)) { user = new FWUser(); user.UserName = name; user.Secret = FWUser.CreateSecret(); user.MultipleIP = LoadIsMultiple(command); _userMan.AddUser(user); _userMan.SaveConfig(); } else if (string.Equals(action, "renew", StringComparison.CurrentCultureIgnoreCase)) { user = _userMan.GetUser(name); if (user == null) { Console.WriteLine("找不到用户:" + name); return; } user.Secret = FWUser.CreateSecret(); user.MultipleIP = LoadIsMultiple(command); _userMan.SaveConfig(); } else { Console.WriteLine("不存在指令:" + action); return; } string json = user.ToJson(); Console.WriteLine("用户配置:" + json); }
private void tsNewUser_Click(object sender, EventArgs e) { using (FrmNewUser frm = new FrmNewUser()) { if (frm.ShowDialog() == DialogResult.OK) { FWUser user = new FWUser(); user.UserName = frm.InputText; user.Secret = FWUser.CreateSecret(); _userMan.AddUser(user); _userMan.SaveConfig(); RefreashUser(); } } }
private void tsRePwd_Click(object sender, EventArgs e) { if (dgMembers.SelectedRows.Count <= 0) { return; } FWUser user = dgMembers.SelectedRows[0].DataBoundItem as FWUser; if (user == null) { return; } user.Secret = FWUser.CreateSecret(); _userMan.SaveConfig(); System.Windows.Forms.MessageBox.Show("重置完毕", "提示"); }