private void lblResetPass_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) { if (string.IsNullOrWhiteSpace(txtUSerEmail.Text.Trim())) { MessageBox.Show("Please type your email Id ,if you have dont remember emailId too please contact admin", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { CreateNewUser _createUser = new CreateNewUser(); User _user = new User { EmailID = txtUSerEmail.Text.ToLower() }; if (!_createUser.IfExists(_user)) { LoginCredentials.LoggedEmailId = txtUSerEmail.Text.ToLower().Trim(); ForgotPassword frmForgotPass = new ForgotPassword(txtUSerEmail.Text.ToLower()); frmForgotPass.ShowDialog(); } else { MessageBox.Show("Email Id you have entered is not registered with our application", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
public async Task AddUserAsync_WhenAllInformationIsCorrect_ShouldReturnUserWithToken(string name, string email, string password) { var sutBuilder = new UserServiceSutBuilder(); var loginDetails = sutBuilder.CreateLoginDetails(email: email, password: password); var user2 = new CreateNewUser { Email = email, Name = name, Password = password, }; var user = user2.ToUser(); var userService = sutBuilder.CreateSut(); A.CallTo(() => sutBuilder.UserRepository.GetByEmailAndPasswordAsync(email, Hasher.GetHashed(password))) .Returns(user); A.CallTo(() => sutBuilder.UserRepository.AddAsync(A <User> .That.Matches(passedUser => passedUser.Name == user.Name && passedUser.Password == Hasher.GetHashed(user.Password) && passedUser.Email == user.Email))) .Returns(user); //Act var resultLogin = await userService.AddUserAsync(user2); //Assert resultLogin.Name.ShouldBe(name); resultLogin.Email.ShouldBe(email); }
public async Task <ActionResult> Register(CreateNewUser model) { if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email, UserRole = model.UserRoles, UserRoleFK = (from Role in db.AspNetRoles.AsEnumerable() where Role.Name == model.UserRoles.ToString() select Role.Id).FirstOrDefault() }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { await this.UserManager.AddToRoleAsync(user.Id, user.UserRole); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); // await this.UserManager.AddToRoleAsync(user.Id, model.UserRoles = model.UserRoles); return(RedirectToAction("ManageAccounts")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <IActionResult> Post([FromBody] CreateNewUser user) { try { if (user.Password == null) { user.Password = Guid.NewGuid().ToString(); } var userModel = _mapper.Map <UserModel>(user); userModel = await _userService.CreateAsync(userModel); var authenticatedUserModel = await _userService.AuthenticateAsync(user.Email, user.Password); var authenticatedUserDto = new AuthenticatedUser() { Id = userModel.Id, Email = authenticatedUserModel.Email, Token = authenticatedUserModel.Token }; var auditActionResult = new AuditActionResult <AuthenticatedUser> { Object = authenticatedUserDto }; return(Ok(auditActionResult)); } catch (Exception ex) { throw; } }
public async Task <ActionResult <UserWithoutPassword> > PostUser(CreateNewUser userToCreate) { System.Diagnostics.Debug.WriteLine($"PostUser: Name: {userToCreate.Name}, Surname {userToCreate.Surname}, ManagerId: {userToCreate.ManagingUserId}, TitleId: {userToCreate.JobTitleId}"); var newUser = await _userService.AddNewUserAsync(userToCreate); var newUserWithoutPassword = new UserWithoutPassword(newUser); return(CreatedAtAction(nameof(GetUser), new { id = newUser.Id }, newUserWithoutPassword)); }
public ActionResult Create(CreateNewUser newUser) { try { if (ModelState.IsValid) { if (CheckValidateEmail(newUser.user.Email)) { if (!ViewModels.CheckForUser(newUser.user.Email)) { if (CheckComplexity(newUser.user.Password)) { newUser.user.Password = Encrypter.ComputeHash(newUser.user.Password, null); Users myUser = new Users(); myUser.Email = newUser.user.Email; myUser.Password = newUser.user.Password; ViewModels.CreateUser(myUser); } else { newUser.passwordError = true; newUser.emailError = false; newUser.blankFieldError = false; newUser.user.Email = null; newUser.user.Password = null; return(View(newUser)); } } else { newUser.emailError = true; newUser.passwordError = false; newUser.blankFieldError = false; newUser.user.Email = null; newUser.user.Password = null; return(View(newUser)); } } else { newUser.emailError = true; newUser.passwordError = false; newUser.blankFieldError = false; newUser.user.Email = null; newUser.user.Password = null; return(View(newUser)); } } return(RedirectToAction("Delete")); } catch (Exception e) { DataLink.LogError(e); throw; } }
public int UserAdd(IUserID user, string[] newuser) { CreateNewUser req = new CreateNewUser(newuser); req.setUser = user; IObjects tmp = req; db.SEND(ref tmp); return(1); }
//reaction for clicking creation of new user option from window menu private void MenuCreateNewUser_Click(object sender, RoutedEventArgs e) { CreateNewUser newUserCreationWindow = new CreateNewUser() { Owner = this, }; newUserCreationWindow.AdditionSuccedeed += NewUserCreationWindow_AdditionSuccedeed; newUserCreationWindow.ShowDialog(); MemoryManagement.FlushMemory(); }
public async Task <SecureChatUser> RegisterNewUser(SecureChatCreateUserRequest userRequest, RSAKeySetIdentity keySetIdentity) { using (var client = new HttpClient()) { client.BaseAddress = new Uri(HostNameURL); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.PostAsJsonAsync("api/securechat/users", userRequest); if (response.IsSuccessStatusCode) { // Get the URI of the created resource. string responceMessage = await response.Content.ReadAsStringAsync(); StringReader sr = new StringReader(responceMessage); JsonReader jsonReader = new JsonTextReader(sr); CreateNewUser createNewUserServerResponce = _jsonSerializer.Deserialize <CreateNewUser>(jsonReader); RSA_AsymetricEncryption rsaAsymetricEncryption = new RSA_AsymetricEncryption(); RSAParameters rsaParameters = rsaAsymetricEncryption.ParseRSAPublicKeyOnlyInfo(keySetIdentity); string aesKey = rsaAsymetricEncryption.DecryptObjectUsingRSA(createNewUserServerResponce.EncodedAESKey, rsaParameters); // Todo decrypt incoming data using AES SecureChatUser secureChatUser = new SecureChatUser(); //register public key //PublicKeyData publicKeyData = new PublicKeyData(); //publicKeyData.GUID = userKeySet.RSA_GUID; //publicKeyData.PublicKey = userKeySet.RSA_PublicKey; //response = await client.PostAsJsonAsync("api/securechat/publickeys", publicKeyData); if (response.IsSuccessStatusCode) { return(secureChatUser); } } } return(null); }
public async Task <User> AddNewUserAsync(CreateNewUser userData) { var manager = await GetUserAsync(userData.ManagingUserId); if (manager == null) { throw new NotFoundException($"Manager with id ({userData.ManagingUserId}) does not exist"); } var userWithEmail = await _schedulearnContext.Users.Where(user => user.Email == userData.Email.ToLower()).FirstOrDefaultAsync(); if (userWithEmail != null) { throw new UniqueConstraintViolatedException("User with this email already exists"); } User newUser = userData.CreateUser(); if (manager.ManagedTeam == null) { var newTeam = await _teamService.AddNewTeamAsync ( new CreateNewTeam() { ManagerId = manager.Id, LimitId = manager.Team?.LimitId ?? manager.LimitId.Value } ); newUser.TeamId = newTeam.Id; } else { newUser.TeamId = manager.ManagedTeam.Id; } Guid newUserGuid = Guid.NewGuid(); newUser.RegistrationGuid = newUserGuid; var link = Regex.Replace(userData.RegisterAddress, "{GUID}", newUserGuid.ToString()); await _schedulearnContext.Users.AddAsync(newUser); await _schedulearnContext.SaveChangesAsync(); await _emailService.SendRegistrationEmail(newUser.Email, newUser.Name, manager.Name, link); return(newUser); }
public async Task <User> AddUserAsync(CreateNewUser newUserData) { newUserData.Validate(); var user = newUserData.ToUser(); user.Password = Hasher.GetHashed(user.Password); var addedUser = await userRepository.AddAsync(user); return(await LoginAsync(new LoginDetails() { Email = addedUser.Email, Password = newUserData.Password })); }
public void AddUserAsync_WhenEmailIsWrong_ShouldThrow(string name, string email) { //Arrange var sutBuilder = new UserServiceSutBuilder(); var user = sutBuilder.CreateUser(name: name, email: email); var user2 = new CreateNewUser { Email = email, Name = name }; var userService = sutBuilder.CreateSut(); //Act & Assert var exception = Assert.ThrowsAsync <ValidationException>(async() => await userService.AddUserAsync(user2)); }
public async Task <User> Handle(CreateNewUser request, CancellationToken cancellationToken) { var result = _dbContext .Users .Add(new User { UserId = request.UserId, FirstName = request.FirstName, LastName = request.LastName, EmailAddress = request.EmailAddress, Created = DateTime.Now }); await _dbContext.SaveChangesAsync(cancellationToken); return(result.Entity); }
//[Category("AllClientReg")] public void TC_CreateUser() { ExtentTestManager Report = new ExtentTestManager(); CreateNewUser cn = new CreateNewUser(); //Boolean userstatus = cn.getNewUser(); //Console.WriteLine("status " + userstatus); try { Assert.IsTrue(cn.getNewUser()); } catch (Exception e) { Report.Fail("User not created"); OneTimeTearDown(); Environment.Exit(0); } }
private async void RegisterButton_Click(object sender, RoutedEventArgs e) { CreateNewUser newUser = new CreateNewUser(); newUser.Name = NameTextBox.Text.Trim(); newUser.Username = UsernameTextBox.Text.Trim(); newUser.Password = PassWordPasswordBox.Password.Trim(); newUser.Email = EmailTextBox.Text.Trim(); newUser.Address = AddressTextBox.Text.Trim(); newUser.Phone = PhoneTextBox.Text.Trim(); newUser.Gender = GenderList.SelectedIndex; bool check = CheckInfo(newUser); if (check) { RequestToApi(newUser); } }
public async Task <IActionResult> Create(string id, CreateNewUser model) { ViewData["Id"] = id; if (ModelState.IsValid) { AppUser user = new AppUser { UserName = model.UserName, FirstName = model.FirstName, LastName = model.LastName, Email = model.Email, CompanyName = model.CompanyName, PhoneNumber = model.PhoneNumber, RegistrationDate = DateTime.Now, Status = model.Status }; IdentityResult result = await userManager.CreateAsync(user, model.Password); if (result.Succeeded) { AppUser newUser = await userManager.FindByNameAsync(model.UserName); IdentityRole role = await roleManager.FindByIdAsync(model.UserRoleId); result = await userManager.AddToRoleAsync(newUser, role.Name); if (result.Succeeded) { return(RedirectToAction("Details", new { id, detailsId = newUser.Id })); } else { ResultError(result); } } else { ResultError(result); } } return(View(model)); }
public async Task <CreateNewResponse> RegisterUser(CreateNewUser user) { try { var isUserExist = await _unitofwork.Users.IsExistingAsync(o => o.Email == user.Email); if (isUserExist) { return new CreateNewResponse { ResponseCode = "01", ResponseMessage = "Email already exist." } } ; else { var addUserResonse = await _unitofwork.Users.AddAsync(new TblUser { Email = user.Email, Firstname = user.Firstname, Lastname = user.Lastname, Password = new Encryptor().EncodePasswordMd5(user.Password), RegistrationTimeStamp = DateTime.Now }); var committed = await _unitofwork.CommitChangesAsync(); if (committed == 1) { return new CreateNewResponse { ResponseCode = "00", ResponseMessage = "User Created Successfully" } } ; else { return new CreateNewResponse { ResponseCode = "02", ResponseMessage = "Something went wrong try again later" } }; } } catch (Exception ex) { _logWriter.LogWrite("Message: " + ex.Message + Environment.NewLine + "InnerException: " + ex.InnerException + Environment.NewLine + "StackTrace: " + ex.StackTrace); return(new CreateNewResponse { ResponseCode = "99", ResponseMessage = ex.Message }); } }
private void btnResetPassword_Click(object sender, EventArgs e) { string GetUserName = LoginCredentials.LoggedEmailId.Substring(0, LoginCredentials.LoggedEmailId.LastIndexOf('@')); CreateNewUser _createUser = new CreateNewUser(); User _user = new User(); _user.Name = GetUserName; _user.Password = txtPassword.Text; _user.ConPassword = txtCnfPassword.Text; if (IsEqual.CompareText(_user.Password, _user.ConPassword)) { if (txtCnfPassword.Text != "" || txtPassword.Text != "") { if (_createUser.ResetPassword(_user)) { MessageBox.Show("Password reset successful !!!", "Alert!!!", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); this.Close(); UserLogin _userLogin = new UserLogin(true); _userLogin.Show(); } else { MessageBox.Show("Unable to change password !!!", "Error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); this.Close(); UserLogin _userLogin = new UserLogin(true); _userLogin.Show(); } } else { MessageBox.Show("Mandatory fields cannot be empty !!!", "Warning!!!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Password does not match", "Error!!!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtCnfPassword.Text = ""; txtPassword.Text = ""; txtPassword.Focus(); } }
//GET: Admin/Create public ActionResult Create() { try { CreateNewUser newUser = new CreateNewUser(); string emailAddress = GetEmailFromToken(FormsAuthentication.FormsCookieName); if (CheckForRootAdmin(emailAddress)) { ViewBag.isAdmin = true; return(View(newUser)); } else { ViewBag.isAdmin = false; return(View(newUser)); } } catch (Exception e) { DataLink.LogError(e); throw; } }
//private void GenderList_SelectionChanged(object sender, SelectionChangedEventArgs e) //{ // SetTextBlockVisibilityCollapsed(); //} public async void RequestToApi(CreateNewUser newUser) { //request POST to api using (var client = new HttpClient()) { var resourceLoader = ResourceLoader.GetForCurrentView(); client.BaseAddress = new Uri(resourceLoader.GetString("ServerURL")); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // New code: try { HttpResponseMessage response = await client.PutAsJsonAsync("api/Users/", newUser); if (response.IsSuccessStatusCode) { var isRegistered = true; this.Frame.Navigate(typeof(SignInPage), isRegistered); } else { ErrorProviderTextBlock.Text = "Username is already existed!"; ErrorProviderTextBlock.Visibility = Visibility.Visible; } } catch (HttpRequestException) { var dialog = new MessageDialog("Can not connect to server!", "Message"); //dialog.Commands.Add(new UICommand("Yes") { Id = 0 }); //dialog.Commands.Add(new UICommand("No") { Id = 1 }); await dialog.ShowAsync(); } } }
void Awake() { createUser = GameObject.Find("ScriptHolder").GetComponent<CreateNewUser>(); }
private bool CheckInfo(CreateNewUser user) { Regex myRegex = null; Match m = null; bool check = true; //check name if (user.Name.Length == 0) { ErrorNameTextBlock.Text = "Please enter your name!"; ErrorNameTextBlock.Visibility = Visibility.Visible; check = false; } //check username if (user.Username.Length == 0) { ErrorUsernameTextBlock.Text = "Please enter your username!"; ErrorUsernameTextBlock.Visibility = Visibility.Visible; check = false; } //check password if (user.Password.Length == 0) { ErrorPasswordTextBlock.Text = "Please enter your password!"; ErrorPasswordTextBlock.Visibility = Visibility.Visible; check = false; } //check password confirm if (ConfirmPassWordPasswordBox.Password.Trim().Length == 0) { ErrorConfirmPasswordTextBlock.Text = "Please confirm your password!"; ErrorConfirmPasswordTextBlock.Visibility = Visibility.Visible; check = false; } else { if (!ConfirmPassWordPasswordBox.Password.Trim().Equals(user.Password)) { ErrorConfirmPasswordTextBlock.Text = "Password not match!"; ErrorConfirmPasswordTextBlock.Visibility = Visibility.Visible; check = false; } } //check email myRegex = new Regex(@"^\w+@\w+[.]\w+$"); m = myRegex.Match(user.Email); if (user.Email.Length == 0) { ErrorEmailTextBlock.Text = "Please enter your email!"; ErrorEmailTextBlock.Visibility = Visibility.Visible; check = false; } else { if (!m.Success) { ErrorEmailTextBlock.Text = "Wrong email format!"; ErrorEmailTextBlock.Visibility = Visibility.Visible; check = false; } } //check address if (user.Address.Length == 0) { ErrorAddressTextBlock.Text = "Please enter your address!"; ErrorAddressTextBlock.Visibility = Visibility.Visible; check = false; } //check phone myRegex = new Regex(@"\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\d{1,14}$"); m = myRegex.Match(user.Phone); if (user.Phone.Length == 0) { ErrorPhoneTextBlock.Text = "Please enter your phone number!"; ErrorPhoneTextBlock.Visibility = Visibility.Visible; check = false; } else { if (!m.Success) { ErrorPhoneTextBlock.Text = "Wrong phone number format!\nPlease input phone number with area code."; ErrorPhoneTextBlock.Visibility = Visibility.Visible; check = false; } } //check gender //if (-1 == user.Gender) //{ // ErrorGenderTextBlock.Text = "Please choose your gender!"; // ErrorGenderTextBlock.Visibility = Visibility.Visible; // check = false; //} return(check); }
void Awake() { createUser = GameObject.Find("ScriptHolder").GetComponent <CreateNewUser>(); }
/// <summary> /// Click to create new user. /// </summary> public void ClickonCreateNewUser() { CreateNewUser.Click(); }
public async Task <IActionResult> Register(CreateNewUser command) { return(Created("", await _mediator.Send(command))); }
public async Task <CreateNewResponse> Register(CreateNewUser user) { return(await _userService.RegisterUser(user)); }
private void ConfirmToCreate() { User _user = new User(); _user.Name = txtname.Text; _user.Password = Password; _user.Gender = cmbGender.Text; _user.DOB = DateTime.Now.ToString("yyyy-MM-dd"); _user.ConPassword = ConfrmPassWord; _user.EmailID = txtEmail.Text; _user.SecurityAns = txtSecurityAns.Text; _user.SecutityQues = CmbSecQues.Text; CreateNewUser _createUser = new CreateNewUser(); string IsEmptyUSer = IsEmpty.CheckIfEmpty_User(_user); if (IsEmptyUSer != null) { MessageBox.Show(IsEmptyUSer, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (IsEqual.CompareText(_user.Password, _user.ConPassword)) { if (IsValidEmail(txtEmail.Text)) { if (txtSecurityAns.Text != "") { if (_createUser.IfExists(_user)) { if (_createUser.CreateUSer(_user)) { MessageBox.Show("New user created sucessfully", "Sucess", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); //UserLogin ul = new UserLogin(true); ApiAuthenticate ul = new ApiAuthenticate(); List<Form> forms = new List<Form>(); // All opened myForm instances foreach (Form f in Application.OpenForms) { forms.Add(f); } // Now let's close opened myForm instances foreach (Form f in forms) { f.Hide(); } ul.ShowDialog(); } else { MessageBox.Show("Unable to create new user", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("EmailID already exists!!!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Please choose a secuity answer cannot be empty", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { MessageBox.Show("Email Id seems to be invalid", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else { if (SpeechModule.GetStatus()) { if (cmbGender.Text != "") { synth.SetOutputToDefaultAudioDevice(); synth.Speak("Password does not match"); synth.Speak("Please say the password again"); txtPassword.Text = ""; txtConfirmPassword.Text = ""; txtPassword.Focus(); } } else MessageBox.Show("Password does not match!!!", "Warning", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning); } } }
/// <summary> /// Click 'Create a new user' on the menu. /// </summary> public void ClickCreateNewUser() { waitForIt(_driver, CreateNewUser); CreateNewUser.WaitAndClick(_driver); }
public async Task <ActionResult <ApiUser> > CreateUser([FromBody] CreateNewUser newUserData) { var user = await userService.AddUserAsync(newUserData); return(mapper.Map <ApiUser>(user)); }
/// <summary> /// /// </summary> public void EditUser() { Window parent = GetCurrentWindow(); CreateNewUser window = new CreateNewUser(userProxy, SelectedUser, UserOperation.Edit); window.Owner = parent; window.ShowDialog(); if (window.DialogResult.HasValue && window.DialogResult.Value) RefreshUsers(string.Empty, null); }