public ActionResult Login(LoginCredentialModel loginCredentials) { UserProcess userProcessor = new UserProcess(); if (ModelState.IsValid) { int result = userProcessor.LoginUser(loginCredentials.Username, MD5HashProvider.CreateMD5Hash(loginCredentials.Password)); if (result == FASTConstant.RETURN_VAL_SUCCESS) { // set the forms auth cookie FormsAuthentication.SetAuthCookie(loginCredentials.Username.ToString(), false); // reset request.isauthenticated var authCookie = System.Web.HttpContext.Current.Request.Cookies[FormsAuthentication.FormsCookieName]; if (authCookie != null) { FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); if (authTicket != null && !authTicket.Expired) { var roles = authTicket.UserData.Split(','); System.Web.HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(new FormsIdentity(authTicket), roles); } } return(RedirectToAction("MyAssets", "Home")); } else { ModelState.AddModelError("", "Wrong Employee Employee ID or Password"); } } return(View()); }
public ActionResult LoginPage(LoginModel model) { //kiểm tra hợp lệ dữ liệu if (ModelState.IsValid) { //gọi hàm đăng nhập trong AdminProcess và gán dữ liệu trong biến model var result = new UserProcess().Login(model.TaiKhoan, model.MatKhau); //Nếu đúng if (result == 1) { //gán Session["LoginAdmin"] bằng dữ liệu đã đăng nhập Session["User"] = model.TaiKhoan; //trả về trang chủ return(RedirectToAction("Index", "Home")); } //nếu tài khoản không tồn tại else if (result == 0) { ModelState.AddModelError("", "Tài khoản không tồn tại."); //return RedirectToAction("LoginPage", "User"); } //nếu nhập sai tài khoản hoặc mật khẩu else if (result == -1) { ModelState.AddModelError("", "Tài khoản hoặc mật khẩu không chính xác"); //return RedirectToAction("LoginPage", "User"); } } return(View()); }
// GET: User/Details/5 public ActionResult Details(int id) { var ep = new UserProcess(); var user = ep.GetById(id); return(View("Details", user)); }
// GET: User/Edit/5 public ActionResult Edit(int id) { var ep = new UserProcess(); var user = ep.GetById(id); return(View("Edit", user)); }
public void When_BlogArticle_is_mapped_to_a_BlogArticleDetailsModel_then_no_data_is_retrieved_from_process_classes() { BlogProcess .Expect(process => process.GetBlogArticle(Arg <Guid> .Is.Anything)) .Repeat.Never(); BlogProcess.Replay(); UserProcess .Expect(process => process.GetUser(Arg <Guid> .Is.Anything)) .Repeat.Never(); UserProcess.Replay(); var blogArticle = BlogArticleCreator.CreateSingle(); var user = UserCreator.CreateSingle(); blogArticle.AuthorId = user.Id; var result = Mapper.MapToDetail(blogArticle, user); Assert.AreEqual(blogArticle.Id, result.Id); Assert.AreEqual(blogArticle.ModificationDate, result.ModificationDate); Assert.AreEqual(blogArticle.PublishDate, result.PublishDate); Assert.AreEqual(blogArticle.Title, result.Title); Assert.AreEqual(blogArticle.Content, result.Content); Assert.AreEqual(blogArticle.CreationDate, result.CreationDate); Assert.AreEqual(user.Login.LoginName, result.AuthorName); }
// GET: User public ActionResult Index() { var ep = new UserProcess(); var lista = ep.GetTop1000(); return(View("Index", lista)); }
public void When_User_is_mapped_to_a_MembershipUser_then_the_User_is_not_retrieved_from_the_IUserProcess() { var user = UserCreator.CreateSingle(); UserProcess .Expect(process => process.GetUser(user.Id)) .Return(user) .Repeat.Never(); UserProcess.Replay(); var result = Mapper.Map(user); Assert.IsNotNull(result); Assert.IsNotNull(result.ProviderUserKey); Assert.AreEqual(user.Id, (Guid)result.ProviderUserKey); //Assert.AreEqual(user.BandId, result.BandId); Assert.AreEqual(user.Login.CreationDate, result.CreationDate.ToUniversalTime()); Assert.AreEqual(user.Login.EmailAddress, result.Email); Assert.AreEqual(user.Login.IsApproved, result.IsApproved); Assert.AreEqual(user.Login.IsLockedOut, result.IsLockedOut); Assert.AreEqual(user.Login.IsOnline, result.IsOnline); Assert.AreEqual(user.Login.LastActivityDate, result.LastActivityDate.ToUniversalTime()); Assert.AreEqual(user.Login.LastLockoutDate, result.LastLockoutDate.ToUniversalTime()); Assert.AreEqual(user.Login.LastLoginDate, result.LastLoginDate.ToUniversalTime()); Assert.AreEqual(user.Login.LastPasswordChangedDate, result.LastPasswordChangedDate.ToUniversalTime()); //Assert.AreEqual(user.ModificationDate, result.ModificationDate); //Assert.AreEqual(user.Name, result.Name); UserProcess.VerifyAllExpectations(); }
public User Map(MembershipUser membershipUser) { if (membershipUser == null) { throw new ArgumentNullException("membershipUser"); } if (membershipUser.ProviderUserKey == null) { throw new ArgumentNullException("membershipUser"); } var id = (Guid)membershipUser.ProviderUserKey; var userFromStore = UserProcess.GetUser(id); userFromStore.Login.EmailAddress = membershipUser.Email; userFromStore.Login.IsApproved = membershipUser.IsApproved; userFromStore.Login.IsLockedOut = membershipUser.IsLockedOut; userFromStore.Login.IsOnline = membershipUser.IsOnline; userFromStore.Login.LastActivityDate = membershipUser.LastActivityDate; userFromStore.Login.LastLockoutDate = membershipUser.LastLockoutDate; userFromStore.Login.LastLoginDate = membershipUser.LastLoginDate; userFromStore.Login.LastPasswordChangedDate = membershipUser.LastPasswordChangedDate; return(userFromStore); }
protected void btnDel_Click(object sender, EventArgs e) { int index = usrGV.SelectedIndex; int itemIdex = usrGV.Rows[index].DataItemIndex; DataTable dt = (Session["upDtSources"] as DataTable).DefaultView.ToTable(); string usrId = dt.Rows[itemIdex]["usrId"].ToString(); UserProcess up = Session["UserProcess"] as UserProcess; up.usrDel(usrId); up.UsrSelfDepartTitleView(); DataTable upTable = up.MyDst.Tables["view_usr_department_title"]; Session["upDtSources"] = upTable; usrGV.DataSource = Session["upDtSources"]; usrGV.DataBind(); Button btn = sender as Button; btn.Visible = false; btn = btnCancel; btn.Visible = false; btn = btnAdd; btn.Visible = true; usrGV.SelectedIndex = -1; usrGV.Enabled = true; }
public void When_ValidateUser_is_called_with_a_valid_UserName_and_a_valid_Password_then_true_is_returned() { const string decryptedPassword = "******"; var user = UserCreator.CreateSingle(); UserProcess .Expect(process => process.GetUserByLoginName(user.Login.LoginName)) .Return(user) .Repeat.Once(); UserProcess.Replay(); CryptographyProcess .Expect(process => process.Decrypt(user.Login.Password)) .Return(decryptedPassword) .Repeat.Once(); CryptographyProcess.Replay(); var result = CustomMembershipProvider.ValidateUser(user.Login.LoginName, decryptedPassword); UserProcess.VerifyAllExpectations(); CryptographyProcess.VerifyAllExpectations(); Assert.IsTrue(result); }
public async Task <IActionResult> PutUserProcess([FromRoute] int id, [FromBody] UserProcess userProcess) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != userProcess.Id) { return(BadRequest()); } _context.Entry(userProcess).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!UserProcessExists(id)) { return(NotFound()); } throw; } return(NoContent()); }
public void When_CreatUser_is_called_with_an_emailAddress_that_already_exists_then_the_MembershipCreateStatus_is_DuplicateEmail() { UserProcess .Expect(process => process.GetUserByLoginName(Arg <string> .Is.Anything)) .Return(null) .Repeat.Once(); UserProcess .Expect(process => process.GetUserByEmailAddress(Arg <string> .Is.Anything)) .Return(UserCreator.CreateSingle()) .Repeat.Once(); UserProcess.Replay(); MembershipCreateStatus createStatus; var result = CustomMembershipProvider.CreateUser( string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, false, Guid.Empty, out createStatus); Assert.IsNull(result); Assert.AreEqual(MembershipCreateStatus.DuplicateEmail, createStatus); }
// GET: User public ActionResult Index() { var controll = new UserProcess(); ViewBag.Login = new UserProcess().LoginViewModel; ViewBag.Register = new UserProcess().RegisterViewModel; return(View()); }
/* * protected void RegisterUser_CreatedUser(object sender, EventArgs e) * { * FormsAuthentication.SetAuthCookie(this.txtUsrName.Text.ToString().Trim(), false); * * string continueUrl = Request.QueryString["ReturnUrl"]; * if (String.IsNullOrEmpty(continueUrl)) * { * continueUrl = "~/"; * } * Response.Redirect(continueUrl); * } */ protected void btnReg_Click(object sender, EventArgs e) { if (inputCheck()) { string usrName = txtUsrName.Text.ToString().Trim(); string realName = txtRealName.Text.ToString().Trim(); string usrMobile = txtMobile.Text.ToString().Trim(); string usrEmail = txtEmail.Text.ToString().Trim(); string departmentId = ddlDepart.SelectedValue.ToString().Trim(); string titleId = ddlTitle.SelectedValue.ToString().Trim(); //int sc = int.Parse(txtContact.Text.ToString().Trim()); #region dataset DataSet dataSet = new DataSet(); DataRow userRow = null; DataColumn colName = new DataColumn("realName", System.Type.GetType("System.String")); DataColumn colUsrName = new DataColumn("usrName", System.Type.GetType("System.String")); DataColumn colUsrMobile = new DataColumn("usrMobile", System.Type.GetType("System.String")); DataColumn colUsrEmail = new DataColumn("usrEmail", System.Type.GetType("System.String")); DataColumn colDepartId = new DataColumn("departmentId", System.Type.GetType("System.String")); DataColumn colTitleId = new DataColumn("titleId", System.Type.GetType("System.String")); DataTable userTable = new DataTable("addTable"); userTable.Columns.Add(colName); userTable.Columns.Add(colUsrName); userTable.Columns.Add(colUsrMobile); userTable.Columns.Add(colUsrEmail); userTable.Columns.Add(colDepartId); userTable.Columns.Add(colTitleId); userRow = userTable.NewRow(); userRow["realName"] = realName; userRow["usrName"] = usrName; userRow["usrMobile"] = usrMobile; userRow["usrEmail"] = usrEmail; userRow["departmentId"] = departmentId; userRow["titleId"] = titleId; userTable.Rows.Add(userRow); dataSet.Tables.Add(userTable); #endregion UserProcess up = new UserProcess(dataSet); string error = up.Add_includeError(); if (string.IsNullOrEmpty(error)) { Response.Redirect("~/Main/usrManagerment/usrInfoManagerment.aspx"); } else { lblName.Text = error; } } }
public IActionResult SignIn(User user) { int error = 0; // Eksik bilgi kontrolü yapılır. if (user != null && user.Email != null && user.Password != null) { using (var uop = new UserProcess(_context)) { var u = uop.List_Users(null); // Liste alınabildi mi kontrolü yapılır. if (u != null) { var log = u.Where(x => x.Email == user.Email && x.Password == user.Password).FirstOrDefault(); // Kullanıcı kayıtlı mı kontrolü yapılır. if (log != null) { identity = new ClaimsIdentity(new[] { new Claim(ClaimTypes.Name, log.FirstName + " " + log.LastName), new Claim(ClaimTypes.Role, log.IsAdmin.ToString()), new Claim(ClaimTypes.Surname, log.UserId.ToString()) }, CookieAuthenticationDefaults.AuthenticationScheme ); isAuthenticated = true; error = 0; } else { error = 1; } // Login işleminin başarılı mı kontrolü yapılır ve session başlatılır. if (isAuthenticated) { var principal = new ClaimsPrincipal(identity); login = HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties { IsPersistent = true, ExpiresUtc = DateTime.UtcNow.AddMinutes(20) }); return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Login", new { er = error })); } else { return(RedirectToAction("Login", new { methodCode = 001, message = "Kullanıcı bilgileri alınamadı." })); } } } else { return(RedirectToAction("Login", new { methodCode = 001, message = "Eksik bilgi!" })); } }
public void UserProcessCreateShouldCreateUser() { var userProcess = new UserProcess(new BaseUnitOfWork(new RepositoryProvider(new RepositoryFactories()))); var user = userProcess.CreateUser("Josh Kaminsky", "*****@*****.**", 0, "p"); user.Discount = 95; userProcess.UpdateUser(user); }
private static bool CheckUnassignedVariables(UserProcess process, ReturningStep currentStep, HashSet <Step> visitedSteps, HashSet <Variable> unassignedVariables, List <string> errors) { visitedSteps.Add(currentStep); unassignedVariables = new HashSet <Variable>(unassignedVariables); // remove variables that currentStep's outputs connect to from the unassigned list foreach (var variable in currentStep.OutputMapping.Values) { unassignedVariables.Remove(variable); } var allValid = true; ICollection <Step> nextSteps; if (currentStep.DefaultReturnPath != null) { nextSteps = new Step[] { currentStep.DefaultReturnPath }; } else if (currentStep.StepType == StepType.Process) { nextSteps = (currentStep as UserStep).ReturnPaths.Values; } else { errors.Add($"Step {currentStep.ID} in process \"{process.Name}\" has no return paths"); return(false); } foreach (var nextStep in nextSteps) { if (visitedSteps.Contains(nextStep)) { continue; // already processed this step, don't do it again } // check each input of nextStep, if it touches anything in unassignedVariables, that's not valid foreach (var variable in nextStep.InputMapping.Values) { if (unassignedVariables.Contains(variable)) { errors.Add($"Step {currentStep.ID} in process \"{process.Name}\" uses a variable before it is assigned: {variable.Name}"); return(false); // once an uninitialized variable is used, stop down this branch } } if (nextStep.StepType == StepType.Process && !CheckUnassignedVariables(process, nextStep as ReturningStep, visitedSteps, unassignedVariables, errors)) { allValid = false; } } return(allValid); }
protected void btnOk_Click(object sender, EventArgs e) { int index = usrGV.SelectedIndex; DropDownList ddl = null; ddl = (usrGV.Rows[index].FindControl("ddlDep") as DropDownList); string strDepId = ddl.SelectedValue.ToString(); ddl.Enabled = false; ddl = (usrGV.Rows[index].FindControl("ddlTitle") as DropDownList); string strTitleId = ddl.SelectedValue.ToString(); ddl.Enabled = false; Button btn = null; btn = (usrGV.Rows[index].FindControl("btnCancle") as Button); btn.Visible = false; btn = sender as Button; btn.Visible = false; UserProcess up = Session["UserProcess"] as UserProcess; DataTable dt = (Session["upDtSources"] as DataTable).DefaultView.ToTable(); int itemIndex = usrGV.Rows[index].DataItemIndex; string oldDepId = dt.Rows[itemIndex]["departmentId"].ToString(); string oldTitleId = dt.Rows[itemIndex]["titleId"].ToString(); if (!strDepId.Equals(oldDepId)) { int usrDepId = int.Parse(dt.Rows[itemIndex]["usrDepId"].ToString()); int usrId = int.Parse(dt.Rows[itemIndex]["usrId"].ToString()); int depId = int.Parse(strDepId); up.SelfUsrDepartUpdate(usrDepId, usrId, depId); } if (!strTitleId.Equals(oldTitleId)) { int usrTitleId = int.Parse(dt.Rows[itemIndex]["usrTitleId"].ToString()); int usrId = int.Parse(dt.Rows[itemIndex]["usrId"].ToString()); int titleId = int.Parse(strTitleId); up.SelfUsrTitleUpdate(usrTitleId, usrId, titleId); } up.UsrSelfDepartTitleView(); DataTable upTable = up.MyDst.Tables["view_usr_department_title"]; Session["upDtSources"] = upTable; usrGV.DataSource = Session["upDtSources"]; usrGV.SelectedIndex = -1; usrGV.DataBind(); }
public UserController( UserManager <ApplicationUser> userManager, SignInManager <ApplicationUser> signInManager, RoleManager <IdentityRole> roleManager, UserProcess userProcess) { _userManager = userManager; _signInManager = signInManager; _roleManager = roleManager; _userProcess = userProcess; }
private static bool CheckUnassignedVariables(UserProcess process, List <string> stepErrors) { var unassignedVariables = new HashSet <Variable>( process.Variables .Where(v => v.InitialValue == null) ); var visitedSteps = new HashSet <Step>(); return(CheckUnassignedVariables(process, process.FirstStep, visitedSteps, unassignedVariables, stepErrors)); }
public async Task <IActionResult> PostUserProcess([FromBody] UserProcess userProcess) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.UserProcess.Add(userProcess); await _context.SaveChangesAsync(); return(CreatedAtAction("GetUserProcess", new { id = userProcess.Id }, userProcess)); }
public void When_ValidateUser_is_called_with_an_invalid_UserName_then_false_is_returned() { UserProcess .Expect(process => process.GetUserByLoginName(Arg <string> .Is.Anything)) .Return(null) .Repeat.Once(); UserProcess.Replay(); var result = CustomMembershipProvider.ValidateUser("userName", "password"); Assert.IsFalse(result); }
protected void Save_Click(object sender, EventArgs e) { UserProcess.InsertUser( new User { Username = Username.Text, UserSurname = surname.Text, Mail = mail.Text, Password = password.Text, IsUserAdmin = false }); Response.Redirect("Default.aspx"); }
public static bool IsServerRunning(bool forCurrentUserOnly) { try { return(UserProcess.IsRunning(ProcessName, forCurrentUserOnly)); } catch (Exception exception) { Log.Error(exception); return(false); } }
public static System.Diagnostics.Process[] GetServerProcesses(bool forCurrentUserOnly) { try { return(UserProcess.GetProcessesByName(ProcessName, forCurrentUserOnly)); } catch (Exception exception) { Log.Error(exception); return(null); } }
public AdminController() { ConnectionHelper _conHelper = new ConnectionHelper { Servername = App.ServerName, Username = App.Username, Password = App.Password, Database = App.AdminDatabaseName }; //ConnectionHelper _conHelper = new ConnectionHelper { Servername = "DESKTOP-NDB4SQT", Username = "******", Password = "******", Database = "BackOfficeAdminDB" }; userProcess = UserProcess.UserProcessMultiton(_conHelper); companyProcess = CompanyProcess.CompanyProcessMultiton(_conHelper); authorityGroupProcess = AuthorityGroupProcess.AuthorityProcessMultiton(_conHelper); companyUserProcess = CompanyUserProcess.CompanyUserProcessMultiton(_conHelper); modulesProcess = ModulesProcess.ModuleProcessMultiton(_conHelper); }
public ClipSyncService() { InitializeComponent(); this.eventLog1 = new EventLog(); if (!EventLog.SourceExists("ClipSyncSource")) { EventLog.CreateEventSource("ClipSyncSource", "ClipSyncLog"); } eventLog1.Source = "ClipSyncSource"; eventLog1.Log = "ClipSyncLog"; _userProcess = new UserProcess(); _userApps = new UserApps(); }
public void When_Index_is_called_GetBlogArticles_on_IBlogProcess_is_called_and_the_result_is_mapped_with_BlogArticleMapper() { var user = UserCreator.CreateSingle(); var blogArticles = BlogArticleCreator.CreateCollection(); foreach (var blogArticle in blogArticles) { blogArticle.AuthorId = user.Id; } UserProcess .Expect(process => process.GetUser(user.Id)) .Return(user) .Repeat.Once(); UserProcess.Replay(); BlogProcess .Expect(process => process.GetBlogArticles()) .Return(blogArticles) .Repeat.Once(); BlogProcess.Replay(); var blogArticleDetailsModelcollection = CreateBlogArticleDetailsModelCollection(); BlogArticleMapper .Expect(mapper => mapper.Map( Arg <IEnumerable <BlogArticle> > .Matches(articles => blogArticles.All(blogArticle => articles.Any(article => article.Id == blogArticle.Id))), Arg <IEnumerable <User> > .Matches(users => users.Any(u => u == user)))) .Return(blogArticleDetailsModelcollection) .Repeat.Once(); BlogArticleMapper.Replay(); var result = Controller.Index().Result as ViewResult; Assert.IsNotNull(result); var model = result.Model as ItemListModel <BlogArticleDetailsModel>; Assert.IsNotNull(model); UserProcess.VerifyAllExpectations(); BlogProcess.VerifyAllExpectations(); BlogArticleMapper.VerifyAllExpectations(); }
//POST: /User/Register : thực hiện lưu dữ liệu đăng ký tài khoản thành viên public ActionResult Register(KhachHang model) { if (ModelState.IsValid) { var user = new UserProcess(); var kh = new KhachHang(); if (user.CheckUsername(model.TaiKhoan, model.MatKhau) == 1) { ModelState.AddModelError("", "Tài khoản đã tồn tại"); } else if (user.CheckUsername(model.TaiKhoan, model.MatKhau) == -1) { ModelState.AddModelError("", "Tài khoản đã tồn tại"); } else { kh.TaiKhoan = model.TaiKhoan; kh.MatKhau = model.MatKhau; kh.TenKH = model.TenKH; kh.Email = model.Email; kh.DiaChi = model.DiaChi; kh.DienThoai = model.DienThoai; kh.NgaySinh = model.NgaySinh; kh.NgayTao = DateTime.Now; kh.TrangThai = false; var result = user.InsertUser(kh); var idUser = db.KhachHangs.FirstOrDefault(n => n.Email == kh.Email && n.TenKH == kh.TenKH); BuildUserTemplate(idUser.MaKH); if (result > 0) { //Session["User"] = result; ModelState.Clear(); //return Redirect("/Home/"); //ModelState.AddModelError("", "Vui Lòng Check Email Kích Hoạt Tài Khoản !"); return(RedirectToAction("KiemTraThongBaoKichHoat", "User")); } else { ModelState.AddModelError("", "Đăng ký không thành công."); } } } return(View(model)); }
public ActionResult Edit(int id, User user) { try { // TODO: Add update logic here var ep = new UserProcess(); ep.Edit(user); return(RedirectToAction("Index")); } catch { return(View()); } }
protected override void AdditionalSetup() { base.AdditionalSetup(); Process = new UserProcess(CatalogsContainer); }