public void AddAndGetUserTest() { Guid newGuid = userManager.AddUser(testUser); User retUser = userManager.GetUserById(newGuid); Assert.IsTrue(testUser.compareStoredProperties(retUser)); }
public ActionResult AjaxAddUser(string FirstName, string LastName, string EmailAdd, string UserName, string Mobile, string UserRole, string TimeZone, string App_Link, string Processer, string sales_ID, string Sales_No, string Birthday, string UserGroup) { objResponse Response = new objResponse(); Users objUsers = new Users(); UserModel objUserModel = new UserModel(); session = new SessionHelper(); try { objUsers.FName = FirstName; objUsers.LName = LastName; objUsers.Email = EmailAdd; objUsers.Username = UserName; objUsers.Mobile = Mobile; objUsers.URole = UserRole; objUsers.TimeZone = TimeZone; objUsers.Agent_App_Link = App_Link; objUsers.Processer = Processer; objUsers.Sales_No = Sales_No; objUsers.Sales_Id = sales_ID; // objUsers.BirthDay = BAL.Helper.Helper.ConvertToDateNullable(Birthday, "MM/dd/yyyy"); objUsers.BirthDay = Birthday; objUsers.Password = BAL.Helper.Helper.GenerateRandomPassword(); objUsers.CratedBy_ID = Convert.ToInt64(session.UserSession.UserId); objUsers.Group = UserGroup; Response = objUserManager.AddUser(objUsers); if (Response.ErrorCode == 0) { if (Response.ErrorMessage != "User Already Exists") { string body = "Dear " + FirstName + " " + LastName + ", <br/><br/>You are successfully registered to ICS. Following are the your account credentials <br/><br/>email address / username : "******"<br/>password : "******"<br/><br/>If you have any questions or trouble logging on please contact to administrator.<br/><br/>All the best,<br/><br/>ICS"; // BAL.Helper.Helper.SendEmail(objUsers.Email, "Welcome To ICS", body); BAL.Helper.Helper.SendEmailUsingGoDaddy(objUsers.Email, "Welcome To ICS", body); objUserModel.users = objUserManager.GetUsers(); return(View(objUserModel)); } else { return(Json("", JsonRequestBehavior.AllowGet)); } } else { return(Json("", JsonRequestBehavior.AllowGet)); } } catch (Exception ex) { BAL.Common.LogManager.LogError("AjaxAddUser Post Method", 1, Convert.ToString(ex.Source), Convert.ToString(ex.Message), Convert.ToString(ex.StackTrace)); return(Json("", JsonRequestBehavior.AllowGet)); } }
public int AddRussianUserWithMinimumAttributs() { User russianUser = new User(); russianUser.UserName = "******"; russianUser.Password = "******"; russianUser.Role = User.Roles.LOF; russianUser.Mail = "notSet"; return(_userManager.AddUser(russianUser)); }
public ApiResult <bool> AddUser(User u) { ApiResult <bool> apiResult = new ApiResult <bool>(); User user = u; user.id = System.Guid.NewGuid().ToString().ToLower(); bool res = userManager.AddUser(user); apiResult.Code = ApiResultStatu.OK; apiResult.Success = true; apiResult.Msg = "成功"; apiResult.Data = res; return(apiResult); }
protected void AddUser() { IRole selectedRole = roles[cb_roleSelect.SelectedIndex]; userManager.AddUser(tb_userId.Text, tb_userPassword.Text, selectedRole); UpdateUsersList(); }
public ActionResult CreateUser([Bind(Include = "Username,FullName,ContactNumber,MCRNo,Role,IsActive,EffectiveStartDate,EffectiveEndDate")] PHSUser user) { if (!IsUserAuthenticated()) { return(RedirectToLogin()); } SetBackURL("Index"); string message = string.Empty; using (var userManager = new UserManager(GetLoginUser())) { string tempPassword = PasswordManager.Generate(); user.Password = tempPassword; var newUserCreated = userManager.AddUser(GetLoginUser(), user, out message); if (!newUserCreated) { SetViewBagError(message); SetBackURL("Index"); return(View()); } SetTempDataMessage(user.Username + " has been created successfully with password " + tempPassword); SetBackURL("Index"); return(RedirectToAction("Index")); } }
public ActionResult Signup(string username, string password, string name) { var mgr = new UserManager(Properties.Settings.Default.ConStr); mgr.AddUser(username, password, name); return(RedirectToAction("Signin")); }
static void Main(string[] args) { Console.WriteLine("Press 1 to create user, 2 to test login"); string choice = Console.ReadLine(); if (choice == "1") { Console.WriteLine("Enter username"); string username = Console.ReadLine(); Console.WriteLine("Enter password"); string password = Console.ReadLine(); var manager = new UserManager(Properties.Settings.Default.ConStr); manager.AddUser(username, password); Console.WriteLine("User created!"); } else { Console.WriteLine("Enter username"); string username = Console.ReadLine(); Console.WriteLine("Enter password"); string password = Console.ReadLine(); var manager = new UserManager(Properties.Settings.Default.ConStr); var user = manager.Login(username, password); if (user == null) { Console.WriteLine("INVALID LOGIN!!!"); } else { Console.WriteLine("WOOHOO!! You're in!"); } } Console.ReadKey(true); }
public ActionResult Add(Student student) { if (ModelState.IsValid) { string error = _studentManager.IsExists(student); if (error != "") { ViewBag.FMsg = "Save failed!! " + error + " Already exists"; return(View(student)); } HttpPostedFileBase image = Request.Files["ImageData"]; bool IsExecute = _studentManager.Add(student, image); if (IsExecute) { User user = new User(); user.UserName = student.Email; user.Password = student.Password; bool execute = _userManager.AddUser(user); return(RedirectToAction("Show")); } else { return(View(student)); } } return(View(student)); }
/// <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 buttonRegister_Click(object sender, EventArgs e) { string newLogin = textBoxLogin.Text, newPassword = textBoxPassword.Text, newPasswordRepeat = textBoxRepeatPassword.Text; if (newPassword != newPasswordRepeat) { MessageBox.Show("Введённые пароли не совпадают.", "", MessageBoxButtons.OK, MessageBoxIcon.Error); textBoxRepeatPassword.Clear(); return; } var addingResult = userManager.AddUser(new User(newLogin), newPassword); if (!addingResult.Succeed) { StringBuilder builder = new StringBuilder("Были обнаружены следующие ошибки:\n"); foreach (string error in addingResult.Errors) { builder.AppendLine(error); } MessageBox.Show(builder.ToString(), "Ошибка регистрации", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MessageBox.Show("Вы успешно зарегистрированы. Используйте имя пользователя и пароль, чтобы войти в систему.", "", MessageBoxButtons.OK, MessageBoxIcon.Information); DialogResult = DialogResult.OK; }
public ActionResult Create(User user) { if (ModelState.IsValid) { using (UserManager manager = new UserManager()) { try { int userId = manager.AddUser(user); user.Id = userId; Security.Identity.Authenticate(user); return(RedirectToAction("Index", "Home")); } catch (ArgumentOutOfRangeException e) { ViewBag.Message = "Please choose another username"; return(View(user)); } } } else { return(View(user)); } }
public ActionResult Signup(string username, string password) { var manager = new UserManager(Properties.Settings.Default.ConStr); manager.AddUser(username, password); return(Redirect("/home/login")); }
private void button1_Click(object sender, EventArgs e) { UserManager uManager = new UserManager(); UserInfo temp = new UserInfo(); temp.Account = account.Text.Trim(); temp.Password = password.Text.Trim(); temp.Name = name.Text; if (radioButton1.Checked == true) { temp.Permission = "look"; } else { temp.Permission = "admin"; } if (radioButton5.Checked == true) { temp.Department = "11"; } else { temp.Department = "12"; } if (uManager.AddUser(temp)) { MessageBox.Show("创建成功"); } }
public string Get(string username) { Console.WriteLine($" string Get(string {username})"); lock (Mutex) { Monitor.Enter(Mutex); } Console.WriteLine("swait"); // mUserManager.SendMessageToAll($"SERV:> {username} has logged in"); var user = mUserManager.AddUser(username); user.MessageArrived += delegate(string message) { Console.WriteLine($"MessageArrived Username = {username}"); lock (Mutex) { this.message = message; Monitor.Pulse(Mutex); } }; lock (Mutex) { Monitor.Wait(Mutex); Monitor.Exit(Mutex); } Console.WriteLine("semaphore.WaitOne();"); return(message); }
public override Task TokenValidated(TokenValidatedContext context) { User user; var identity = context.Ticket.Principal.Identity as ClaimsIdentity; if (identity == null) { return(Task.FromException <ArgumentNullException>(new ArgumentNullException())); } // Just a Hack to avoid concurrency lock (this) { try { user = _userManager.GetUserByEmail(identity.Name); } catch (InvalidOperationException) { user = new User { Email = identity.Name, Role = Role.Student }; _userManager.AddUser(user); } } // Adding Claims for the current request user. identity.AddClaim(new Claim("Id", user.Id.ToString())); identity.AddClaim(new Claim(ClaimTypes.Email, user.Email)); identity.AddClaim(new Claim(ClaimTypes.Role, user.Role)); return(Task.FromResult(0)); }
public virtual IActionResult Index() { userManager.AddUser(); userManager.DelUser(); return(View()); }
public HttpResponseMessage AddUser([FromBody] UserModel userModel) { using (logic = new UserManager()) { try { //בדיקה האם הפרמטר שעבר לפונקציה בתור מודל עומד בדרישות הואלידציה //BOהגדרות הואלידציה מוגדרות בתוך ה //Data annotation בתור if (!ModelState.IsValid) { string error = ModelState.Where(ms => ms.Value.Errors.Any()).Select(ms => ms.Value.Errors[0].ErrorMessage).FirstOrDefault(); return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, error)); } // הולידציה עברה בהצלחה userModel = logic.AddUser(userModel); return(Request.CreateResponse(HttpStatusCode.Created, userModel)); } catch (Exception ex) { return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ExceptionHelper.GetInnerMessage(ex))); } } }
private static void SeedGlobalAdmins(UserManager <ApplicationUser> userManager, IConfiguration configuration) { var globalAdmins = configuration.GetSection("GlobalAdmins") .GetChildren() .ToList() .Select(x => ( x.GetValue <string>("UserName"), x.GetValue <string>("Password"))) //.ToList<(string UserName, string Password)>() .ToDictionary(k => k.Item1, k => k.Item2, StringComparer.InvariantCultureIgnoreCase); foreach (var globalAdmin in globalAdmins) { ApplicationUser user = userManager.AddUser(globalAdmin.Key, globalAdmin.Value, nameof(UserRole.Admin)); if (!user.GlobalAdmin) { user.GlobalAdmin = true; userManager.UpdateAsync(user).Wait(); } } foreach (ApplicationUser user in userManager.Users.Where(x => !globalAdmins.ContainsKey(x.UserName))) { if (user.GlobalAdmin) { user.GlobalAdmin = false; userManager.UpdateAsync(user).Wait(); } } }
/// <inheritdoc /> public void UserJoin(GameObject userGO, IUserInfo userInfo) { void PerformUserJoin() { var user = userGO.GetComponents <User>() .FirstOrDefault(_user => _user.AppInstanceId == this.InstanceId); if (user == null) { user = userGO.AddComponent <User>(); user.Initialize(userInfo, this); } Protocol.Send(new UserJoined() { User = new UserPatch(user) }); LocalUser = user; // TODO @tombu - Wait for the app to send back a success for join? _userManager.AddUser(user); OnUserJoined?.Invoke(userInfo); } if (Protocol is Execution) { PerformUserJoin(); } else { _executionProtocolActionQueue.Add(() => PerformUserJoin()); } }
public ActionResult SignUp(User user) { UserManager um = new UserManager(); um.AddUser(user); return(RedirectToAction("UserLandingPage", "Landing")); }
private void btnAdd_Click(object sender, EventArgs e) { string strName = txtName.Text; string strPwd = txtPwd.Text; int role = 0; if (rbAdmin.Checked) { role = 1; } if (string.IsNullOrEmpty(strName)) { MessageBox.Show("密码不能为空", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); txtPwd.Focus(); return; } User user = new User(strName, strPwd, role); if (UserManager.AddUser(user)) { MessageBox.Show("添加成功"); } else { MessageBox.Show("添加失败"); } }
public static void SelectOption() { Console.WriteLine("Select option: "); Console.WriteLine("1) Add User"); Console.WriteLine("2) Remove User"); Console.WriteLine("3) Show all users"); Console.WriteLine("4) Close app"); var input = Console.ReadLine(); int option = 0; while (option != 4) { if (int.TryParse(input, out option) && option > 0 && option < 5) { string name = "", dateofbirth = ""; switch (option) { case 1: ReadUserInfo(ref name, ref dateofbirth); try { userManagerLogic.AddUser(name, dateofbirth); } catch (Exception e) { Console.WriteLine(e.Message); } break; case 2: ReadUserInfo(ref name, ref dateofbirth); try { userManagerLogic.RemoveUser(name, dateofbirth); } catch (Exception e) { Console.WriteLine(e.Message); } break; case 3: WriteAllUsers(userManagerLogic.GetAllUsers()); break; case 4: userManagerLogic.SaveData(); Environment.Exit(0); break; } } else { Console.WriteLine("Invalid number, try again"); } Console.Write("Select option: "); input = Console.ReadLine(); } }
public ActionResult Register(string firstName, string lastName, string email, string password) { var manager = new UserManager(Properties.Settings.Default.ConStr); int userId = manager.AddUser(firstName, lastName, email, password); FormsAuthentication.SetAuthCookie(userId.ToString(), true); return(Redirect("/home/index")); }
public ActionResult AddUser(string username, string name, string password) { var mgr = new UserManager(Properties.Settings.Default.ContstrAuth); mgr.AddUser(username, password, name); return(RedirectToAction("Login")); }
public IActionResult SignUp(User user) { UserManager mgr = new UserManager(_connectionString); user.Password = BCrypt.Net.BCrypt.HashPassword(user.Password); mgr.AddUser(user); return(Redirect("/user/logIn")); }
public ActionResult Signup(string firstName, string lastName, string emailAddress, string password) { var manager = new UserManager(Properties.Settings.Default.ConStr); manager.AddUser(firstName, lastName, emailAddress, password); FormsAuthentication.SetAuthCookie(emailAddress, true); return(Redirect("/")); }
public int AddUser(UsersEntity user) { this.ClearBrokenRuleMessages(); int id = mgr.AddUser(user); this.AddBrokenRuleMessages(mgr.BrokenRuleMessages); return(id); }
public void AddUserTest() { var expectedUser = GetNewMockUser(); userManager.AddUser(expectedUser); var actualUser = dataContext.User.First(x => x.UserId == expectedUser.UserId); Assert.IsNotNull(actualUser); Assert.AreEqual(expectedUser.GetHashCode(), actualUser.GetHashCode()); }
private static void AddUser1() { UserManager userManager = new UserManager(new EfUserDal()); User cr1 = new User { FirstName = "grkm", LastName = "ark", Email = "qwjeıqwjeqw" }; Console.WriteLine(userManager.AddUser(cr1).Message); }
public void AddUserTest() { // act _userRepositoryMock.Setup(x => x.Add(It.IsAny<User>())); var userManager = new UserManager(_userRepositoryMock.Object); // actual var actual = userManager.AddUser("test"); // assert Assert.AreEqual(actual.Username, "test"); }
public RedirectToRouteResult Add(UserModel user) { UserManager manager = new UserManager(); manager.AddUser(user.UserName, user.Password, user.ClientId, user.ClientName); return RedirectToAction("Index", "Home"); }