protected void Page_Load(object sender, EventArgs e) { IncludeJs("LoginEncrytDecryt", "/Modules/Admin/LoginControl/js/AESEncrytDecryt.js"); IncludeCss("PasswordRecovery", "/Modules/WebbuilderHelper/css/login.css"); ForgotPasswordInfo objInfo = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_HELP, GetPortalID); if (objInfo != null) { helpTemplate = objInfo.Body; } if (!IsPostBack) { if (Request.QueryString["RecoveringCode"] != null) { QueryValue = Request.QueryString["RecoveringCode"].ToString(); try { rfvConfirmPass.Visible = true; rfvPassword.Visible = true; cmpPassword.Visible = true; QueryValue = EncryptionMD5.Decrypt(QueryValue); sageframeuser = UserManagementController.GetUsernameByActivationOrRecoveryCode(QueryValue, GetPortalID); if (sageframeuser.CodeForUsername != null) { if (sageframeuser.IsAlreadyUsed) { FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("PasswordRecovery", "RecoveryCodeAlreadyActivated")); divRecoverPasswordFrom.Visible = false; } else { hdnUserName.Value = sageframeuser.CodeForUsername; divRecoverPasswordFrom.Visible = true; } } else { divRecoverPasswordFrom.Visible = false; FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserManagement", "UserDoesNotExist")); } } catch (Exception ex) { divRecoverPasswordFrom.Visible = false; FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("PasswordRecovery", "InvalidRecoveringCode")); } } else { divRecoverPasswordFrom.Visible = false; FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("PasswordRecovery", "RecoveringCodeIsNotAvailable")); } } }
public void HandlePostRegistration(int UserRegistrationType) { switch (UserRegistrationType) { case 0: ForgotPasswordInfo template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_NONE, GetPortalID); if (template != null) { USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body; } break; case 1: template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_PRIVATE, GetPortalID); if (template != null) { USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body; } this.divRegistration.Visible = true; this.divRegConfirm.Visible = true; this.divRegister.Visible = false; break; case 3: template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_VERIFIED, GetPortalID); if (template != null) { USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body; } List <ForgotPasswordInfo> objFpwd = UserManagementController.GetMessageTemplateListByMessageTemplateTypeID(SystemSetting.ACCOUNT_ACTIVATION_EMAIL, GetPortalID); foreach (ForgotPasswordInfo messageTemplate in objFpwd) { CommonFunction comm = new CommonFunction(); DataTable dtActivationTokenValues = UserManagementController.GetActivationTokenValue(UserName.Text, GetPortalID); string replaceMessageSubject = MessageToken.ReplaceAllMessageToken(messageTemplate.Subject, dtActivationTokenValues); string replacedMessageTemplate = MessageToken.ReplaceAllMessageToken(messageTemplate.Body, dtActivationTokenValues); MailHelper.SendMailNoAttachment(messageTemplate.MailFrom, Email.Text, replaceMessageSubject, replacedMessageTemplate, string.Empty, string.Empty); } // CheckDivVisibility(false, true); this.divRegistration.Visible = true; this.divRegConfirm.Visible = true; this.divRegister.Visible = false; break; case 2: template = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.USER_RESISTER_SUCESSFUL_INFORMATION_PUBLIC, GetPortalID); if (template != null) { USER_RESISTER_SUCESSFUL_INFORMATION.Text = template.Body; } LogInPublicModeRegistration(); break; } }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); // AreaRegistration.RegisterAllAreas(); UserManagementController.RegisterMe(); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } ); }
private void Form1_Load(object sender, EventArgs e) { UserManagementController userManagementController = new UserManagementController(); User currentUser = new User(); currentUser = userManagementController.GetLoggedInUser("5e6624de1c9d4400008a5134"); lblCurrentFirstName.Text = currentUser.firstName; lblCurrentLastName.Text = currentUser.lastName; lblCurrentEmail.Text = currentUser.email; lblCurrentPhone.Text = currentUser.phoneNumber.ToString(); }
public void GetIndex_ReturnsView() { //arrange var repository = new Mock <IUsersRepository>(); var userManagement = new UserManagementController(repository.Object); //act var result = userManagement.Index() as ViewResult; //assert Assert.That(result, Is.Not.Null); }
public void GetUserTest() { var controller = new UserManagementController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var response = controller.Get(1); Assert.AreEqual(response.UserID, 1); Assert.AreEqual("Riyaz", response.FirstName); }
protected void Page_Load(object sender, EventArgs e) { ForgotPasswordInfo objInfo = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_RECOVERED_HELP, GetPortalID); if (objInfo != null) { helpTemplate = objInfo.Body; } if (!IsPostBack) { string RecoveringCode = string.Empty; if (Request.QueryString["RecoveringCode"] != null) { RecoveringCode = Request.QueryString["RecoveringCode"].ToString(); try { RecoveringCode = EncryptionMD5.Decrypt(RecoveringCode); hdnRecoveryCode.Value = RecoveringCode; AddImageUrls(); sageframeuser = UserManagementController.GetUsernameByActivationOrRecoveryCode(hdnRecoveryCode.Value, GetPortalID); if (sageframeuser.CodeForUsername != null) { if (sageframeuser.IsAlreadyUsed) { ShowMessage("", GetSageMessage("PasswordRecovery", "RecoveryCodeAlreadyActivated"), "", SageMessageType.Alert); divRecoverpwd.Visible = false; } else { divRecoverpwd.Visible = true; } } else { divRecoverpwd.Visible = false; ShowMessage("", GetSageMessage("UserManagement", "UserDoesNotExist"), "", SageMessageType.Alert); } } catch { ShowMessage("", GetSageMessage("PasswordRecovery", "InvalidRecoveringCode"), "", SageMessageType.Alert); divRecoverpwd.Visible = false; } } else { ShowMessage("", GetSageMessage("PasswordRecovery", "RecoveringCodeIsNotAvailable"), "", SageMessageType.Error); divRecoverpwd.Visible = false; } SetValidatorErrorMessage(); } }
public void GetAllUsersTest() { var controller = new UserManagementController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var response = controller.Get(); Assert.IsNotEmpty(response); }
public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); UserManagementController.RegisterMe(); routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ); }
public void CreateNewUser_NonexistingManager_404() { var controller = new UserManagementController(); var admin = _ut.CreateUserObject(); admin.IsAdministrator = true; var adminSession = _ut.CreateSessionObject(admin); _ut.CreateSessionInDb(adminSession); var nonexistingdManagerId = Guid.NewGuid(); // modify user var newUser = new { username = Guid.NewGuid() + "@mail.com", city = "Long Beach", state = "California", country = "USA", manager = nonexistingdManagerId.ToString(), isadmin = false, disabled = false, }; // mock payload var mock_payload = new CreateUserRequestDTO { Username = newUser.username, City = newUser.city, State = newUser.state, Country = newUser.country, Manager = newUser.manager, IsAdmin = newUser.isadmin, Disabled = newUser.disabled }; var expectedStatusCode = HttpStatusCode.NotFound; var endpoint = API_Route_Local + "/user/update"; controller.Request = new HttpRequestMessage { RequestUri = new Uri(endpoint) }; controller.Request.Headers.Add("token", adminSession.Token); NegotiatedContentResult <string> actionresult = (NegotiatedContentResult <string>)controller.CreateNewUser(mock_payload); Assert.AreEqual(expectedStatusCode, actionresult.StatusCode); }
public void Setup() { _container = new MocksAndStubsContainer(); _applicationSettings = _container.ApplicationSettings; _context = _container.UserContext; _pageRepository = _container.PageRepository; _userRepository = _container.UserRepository; _settingsService = _container.SettingsService; _userService = _container.UserService; _controller = new UserManagementController(_applicationSettings, _userService, _settingsService, _context); }
public void UpdateDog_PutQuerySuccessfullyExecuted_ReturnsOkObjectResult() { var id = Guid.NewGuid(); var dog = new DogForUpdate(); var userManagementServiceMock = new Mock <IUserManagementService>(); userManagementServiceMock.Setup(x => x.UpdateDog(id, dog)); var userManagementController = new UserManagementController(userManagementServiceMock.Object); var result = userManagementController.Update(id, dog); Assert.IsTrue(result.GetType() == typeof(OkObjectResult)); }
public void UpdateUserTest() { var controller = new UserManagementController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); var user = controller.Get(1); user.EmployeeID = 456789; string result = controller.Put(user); Assert.AreEqual("Record updated Successfully", result); }
public void GetUserById_GetQuerySuccessfullyExecute_ReturnsOkObjectResult() { var id = Guid.NewGuid(); var user = new UserForDisplay(); var userManagementServiceMock = new Mock <IUserManagementService>(); userManagementServiceMock.Setup(x => x.GetUserById(id)) .Returns(user); var userManagementController = new UserManagementController(userManagementServiceMock.Object); var result = userManagementController.GetUserById(id); Assert.IsTrue(result.GetType() == typeof(OkObjectResult)); }
private void btnUpdateUserData_Click(object sender, EventArgs e) { UserManagementController userManagementController = new UserManagementController(); User user = new User(); //get new data string newFirstName = textBoxFirstName.Text; string newLastName = textBoxLastName.Text; string newEmail = textBoxEmail.Text; string newPhone = textBoxPhone.Text; //gooi dit in een aparte methode (validate data) if (string.IsNullOrEmpty(newFirstName)) { newFirstName = lblCurrentFirstName.Text; } if (string.IsNullOrEmpty(newLastName)) { newLastName = lblCurrentLastName.Text; } if (string.IsNullOrEmpty(newEmail)) // REGEX check { newEmail = lblCurrentEmail.Text; } if (string.IsNullOrEmpty(newPhone)) // REGEX check { newPhone = lblCurrentPhone.Text; } //put data in user object user.firstName = newFirstName; user.lastName = newLastName; user.email = newEmail; user.phoneNumber = int.Parse(newPhone); //go to logic layer userManagementController.UpdateUser("5e6624de1c9d4400008a5134", user); //empty textboxes textBoxFirstName.Text = ""; textBoxLastName.Text = ""; textBoxEmail.Text = ""; textBoxPhone.Text = ""; }
protected void Page_Load(object sender, EventArgs e) { IncludeLanguageJS(); ForgotPasswordInfo objInfo = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_FORGOT_HELP, GetPortalID); if (objInfo != null) { helpTemplate = "<b>" + objInfo.Body + "</b>"; } if (!IsPostBack) { InitializeCaptcha(); GenerateCaptchaImage(); //SetValidatorErrorMessage(); } }
public void DisableUser() { // Arrange var controller = new UserManagementController(); UserManagementDTO obj = new UserManagementDTO() { UserName = "******" }; // Act IHttpActionResult actionResult = controller.DisableUser(obj); var contentResult = actionResult as OkNegotiatedContentResult <string>; // Assert Assert.NotNull(contentResult); Assert.NotNull(contentResult.Content); Assert.Equal("Success: Account was deleted for amay", contentResult.Content); }
/// <summary> /// metod za dodavanje na nova fukcija na korisnik. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button4_Click(object sender, EventArgs e) { List <int> list = new List <int>(); foreach (ListItem item in RoleFunctionsList.Items) { if (item.Enabled) { list.Add(Convert.ToInt32(item.Value)); } } int userId = Convert.ToInt32(ddlUsers.SelectedValue); //funkcija za azuriranje na funkciite na korisnik. UserManagementController.updateUser(userId, list); RegisterStartupScript("myAlert", "<script>alert('Успешно доделување/одземање на функции.')</script>"); }
public void UpdateUser_NonexistingManager_404() { var controller = new UserManagementController(); var admin = _ut.CreateUserObject(); admin.IsAdministrator = true; var adminSession = _ut.CreateSessionObject(admin); _ut.CreateSessionInDb(adminSession); var existingUser = _ut.CreateUserInDb(); var nonexistingManagerId = Guid.NewGuid(); // modify user var modifiedUser = _ut.CreateUserObject(); modifiedUser.Id = existingUser.Id; modifiedUser.IsAdministrator = existingUser.IsAdministrator; modifiedUser.ManagerId = nonexistingManagerId; // mock payload var mock_payload = new UpdateUserRequestDTO { Id = modifiedUser.Id.ToString(), City = modifiedUser.City, State = modifiedUser.State, Country = modifiedUser.Country, Manager = modifiedUser.ManagerId.ToString(), IsAdmin = modifiedUser.IsAdministrator, Disabled = modifiedUser.Disabled }; var expectedStatusCode = HttpStatusCode.NotFound; var endpoint = API_Route_Local + "/user/update"; controller.Request = new HttpRequestMessage { RequestUri = new Uri(endpoint) }; controller.Request.Headers.Add("token", adminSession.Token); NegotiatedContentResult <string> actionresult = (NegotiatedContentResult <string>)controller.UpdateUser(mock_payload); Assert.AreEqual(expectedStatusCode, actionresult.StatusCode); }
public void AddUserTest() { var controller = new UserManagementController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); User user = new User(); user.EmployeeID = 3412342; user.FirstName = "Test Test"; user.LastName = "Test"; string result = controller.Post(user); Assert.AreEqual("Record added Successfully", result); }
public void NoSessionToken_Unauthorized_401() { var controller = new UserManagementController(); var expectedStatusCode = HttpStatusCode.Unauthorized; var endpoint = API_Route_Local + "/users"; controller.Request = new HttpRequestMessage { RequestUri = new Uri(endpoint) }; // no token header was added to request NegotiatedContentResult <string> actionresult = (NegotiatedContentResult <string>)controller.GetAllUsers(); Assert.AreEqual(expectedStatusCode, actionresult.StatusCode); }
public async Task RedirectToActionIndexWhenInvoked() { //Arrange var userServiceMock = new Mock <IUserService>(); var twitterAccountServiceMock = new Mock <ITwitterAccountService>(); var tweetServiceMock = new Mock <ITweetService>(); var model = new Mock <EditViewModel>(); var controller = new UserManagementController ( userServiceMock.Object, twitterAccountServiceMock.Object, tweetServiceMock.Object ); //Act & Assert var result = await controller.Edit(model.Object) as RedirectToActionResult; Assert.AreEqual("Index", result.ActionName); }
public string[] GetUsernameList(string prefixText, int count) { List <string> items = new List <string>(); try { BaseUserControl suc = new BaseUserControl(); List <UserManagementInfo> objList = UserManagementController.GetUsernameByPortalIDAuto(prefixText, 12, count, suc.GetUsername); foreach (UserManagementInfo objInfo in objList) { items.Add(objInfo.UserName); } return(items.ToArray()); } catch { return(items.ToArray()); } }
public void BanTest() { var user = new UserProfile { Id = "1", UserName = "******", LockoutEnabled = false }; // Arrange var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "users") .UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking) .Options; var context = new ApplicationDbContext(options); var emailSender = new Mock <IEmailSender>(); var taskRep = new Mock <TaskRepository>(context); var userRep = new Mock <UserRepository>(context); var mapper = new Mock <IMapper>(); var userService = new Mock <UserService>(userRep.Object, mapper.Object); userService.Setup(i => i.GetUserProfile("1")).Returns(user); var catRep = new Mock <CategoryRepository>(context); var taskCatRep = new Mock <TaskCategoryRepository>(context); var service = new Mock <TaskService>(taskRep.Object, userRep.Object, catRep.Object, taskCatRep.Object, mapper.Object); var mockUserManager = new Mock <UserManager <UserProfile> >( new Mock <IUserStore <UserProfile> >().Object, new Mock <IOptions <IdentityOptions> >().Object, new Mock <IPasswordHasher <UserProfile> >().Object, new IUserValidator <UserProfile> [0], new IPasswordValidator <UserProfile> [0], new Mock <ILookupNormalizer>().Object, new Mock <IdentityErrorDescriber>().Object, new Mock <IServiceProvider>().Object, new Mock <ILogger <UserManager <UserProfile> > >().Object); var controller = new UserManagementController(mockUserManager.Object, service.Object, userService.Object, emailSender.Object); var view = controller.Ban("1"); Assert.IsType <JsonResult>(view); }
public void CreateInstance_WhenInvokedWithValidParameters() { //Arrange var userServiceMock = new Mock <IUserService>(); var twitterAccountServiceMock = new Mock <ITwitterAccountService>(); var tweetServiceMock = new Mock <ITweetService>(); //Act var userManagementController = new UserManagementController ( userServiceMock.Object, twitterAccountServiceMock.Object, tweetServiceMock.Object ); //Assert Assert.IsNotNull(userManagementController); Assert.IsInstanceOfType(userManagementController, typeof(UserManagementController)); }
public async Task ReturnIndexViewWhenInvoked() { //Arrange var userServiceMock = new Mock <IUserService>(); var twitterAccountServiceMock = new Mock <ITwitterAccountService>(); var tweetServiceMock = new Mock <ITweetService>(); var controller = new UserManagementController ( userServiceMock.Object, twitterAccountServiceMock.Object, tweetServiceMock.Object ); //Act & Assert var result = await controller.Index() as ViewResult; Assert.AreEqual("Index", result.ViewName); }
public async Task RedirectToActionDetailsWhenInvoked() { //Arrange var userServiceMock = new Mock <IUserService>(); var twitterAccountServiceMock = new Mock <ITwitterAccountService>(); var tweetServiceMock = new Mock <ITweetService>(); var controller = new UserManagementController ( userServiceMock.Object, twitterAccountServiceMock.Object, tweetServiceMock.Object ); //Act & Assert var result = await controller.DeleteTwitterAccount("2", "5") as RedirectToActionResult; Assert.AreEqual("Details", result.ActionName); }
/// <summary> /// metod za prikaz na site funkcii po korisnik. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void RoleFunctionsList_DataBound(object sender, EventArgs e) { if (IsPostBack) { List <int> functions = new List <int>(); foreach (ListItem item in RoleFunctionsList.Items) { item.Selected = true; functions.Add(Convert.ToInt32(item.Value)); } bool[] enabled = new bool[functions.Count]; int userId = Convert.ToInt32(ddlUsers.SelectedValue); UserManagementController.fillEnabled(userId, enabled, functions); int c = 0; foreach (ListItem item in RoleFunctionsList.Items) { item.Enabled = enabled[c++]; } } }
protected override bool OnServerSideEvaluate() { String username = GetControlValidationValue("UserLoginId"); String originalUsername = ((HiddenField)FindControl("OriginalUserLoginId")).Value; if (String.IsNullOrEmpty(username)) { ErrorMessage = ValidationErrors.UserIDCannotBeEmpty; return(false); } var controller = new UserManagementController(); if (controller.ExistsUsername(username) && !username.Equals(originalUsername)) { ErrorMessage = String.Format(ValidationErrors.UsernameAlreadyExists, username); return(false); } return(true); }
protected void Page_Load(object sender, EventArgs e) { //var template = dbMessageTemplate.sp_MessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_FORGET_HELP, GetPortalID).SingleOrDefault(); ForgetPasswordInfo objInfo = UserManagementController.GetMessageTemplateByMessageTemplateTypeID(SystemSetting.PASSWORD_FORGET_HELP, GetPortalID); //if (template != null) //{ // helpTemplate = "<b>" + template.Body+ "</b>"; //} if (objInfo != null) { helpTemplate = "<b>" + objInfo.Body + "</b>"; } IsUseFriendlyUrls = pb.GetSettingBollByKey(SageFrameSettingKeys.UseFriendlyUrls); if (!IsPostBack) { SetValidatorErrorMessage(); } }