public ActionResult LogOn(Login login, string returnUrl) { if (!ValidateLogOn(login.username, login.password)) { return(View("Login")); } if (LoginServices.ValidateUser(login, Response)) { if (!string.IsNullOrEmpty(returnUrl)) { return(Redirect(returnUrl)); } else { if (BaseController.CurrentUser.UserType == enumUserType.Admin) { return(RedirectToAction("ApplicationsList", "Applications")); } else { return(RedirectToAction("AppDashboard", "ApplicationDashboard")); } } } else { ModelState.AddModelError("", "Invalid username or password."); return(View("Login")); } }
public object Post( [FromBody] LoginViewModel usuario, [FromServices] LoginServices _loginServices, [FromServices] IMapper _mapper) { return(_loginServices.FazerLogin(_mapper.Map <LoginViewModel, LoginDto>(usuario))); }
public User Get(string name, string password) { LoginServices oLoginService = new LoginServices(); var ouser = oLoginService.UserLogin(name, password); return(ouser); }
public string CanLogin() { var userLogin = new UserLoginDto { UserName = User, Password = Password, Environment = Environment }; try { MyTestInitialize(); EnvironmentServices.SetEnvironment(Environment); UserServices.ConfigureSystemUser(); LoginServices.Login(userLogin); var result = LoginServices.IsLoggedIn(userLogin.UserName).ToString(CultureInfo.InvariantCulture); MyTestCleanup(); return(result); } catch (System.Exception) { return("False"); } }
public ExceptionTest() { _UserService = new UserServices(_session); _AdminService = new AdminServices(_session); _BankService = new BankServices(_session); _LoginService = new LoginServices(_session); }
//check for a login existence public async Task <bool> VerifyLogin(string username, string password) { var loginServices = new LoginServices(); bool result = await loginServices.CheckLogin(username, password); return(result); }
public static List <Employee> GetAllEmployeesForDept(string sessionId) { var user = LoginServices.GetUserBySessionId(sessionId); List <Employee> list = db.employees.Where(x => x.Role == "DEPT_EMPLOYEE" && x.Dept_Id == user.Dept_Id).ToList(); return(list); }
public void ReturnFalseWhenValidUserLoginButDifferentUser() { Isolate.WhenCalled(() => _principal.IsLoggedIn()).WillReturn(true); Isolate.WhenCalled(() => _identity.Name).WillReturn("John"); Assert.IsFalse(LoginServices.IsLoggedIn(_dto.UserName)); }
//Encerra o programa public void CloseWindow() { if (LoginServices != null) { LoginServices.CloseWindow(); } }
public void ReturnFalseWhenAdminUserHasNotPasswordFoo() { IsolateUserHasPasswordMethod(); _dto.Password = "******"; Assert.IsFalse(LoginServices.UserHasPassword(_dto)); }
public void ReturnTrueWhenValidUserLogin() { Isolate.WhenCalled(() => _principal.IsLoggedIn()).WillReturn(true); Isolate.WhenCalled(() => _identity.Name).WillReturn(_dto.UserName); Assert.IsTrue(LoginServices.IsLoggedIn(_dto.UserName)); }
private void UpdateLoginState(string username, bool isLoginFail, int loginFail) { LoginServices service = new LoginServices(); string strDangNhapThanhCong = "1"; string strOnline = "1"; string strLoginFail = ""; if (string.IsNullOrEmpty(username)) { username = Session["loginid"].ToString(); } if (isLoginFail) { strDangNhapThanhCong = strOnline = "0"; strLoginFail = (loginFail + 1).ToString(); Session[strSessionLoginFail] = loginFail + 1; ViewBag.strAlert = string.Format("Đăng nhập không thành công! <br/>(đăng nhập sai {0}/{1})", strLoginFail, CST_Common.CST_Lock); } if (loginFail == 0 && !isLoginFail) { strLoginFail = "0"; } if (service.CheckExistUserInfoHistory(username, this.Session.SessionID)) { service.UpdateHistoryLogin(username, this.Session.SessionID, strLoginFail, strDangNhapThanhCong, strOnline); } else { service.InsertHistoryLogin(username, this.Session.SessionID, Log4Net.clientIP, Log4Net.browser, Log4Net.useragent, strLoginFail, strDangNhapThanhCong, strOnline); } }
public void EnterToMailLstPageTest() { LoginServices s = new LoginServices(driver); s.gotoMailList(); Assert.IsTrue(s.signOutExists()); }
public void EnterToLoginPageTest() { LoginServices s = new LoginServices(driver); s.goToLoginPage(); Assert.IsTrue(s.singUpExists()); }
//post a login object private async Task <bool> PostLoginAsync() { var loginServices = new LoginServices(); var response = await loginServices.PostLogin(logindetails); return(response); }
private void ValidarLogin(object parameter) { var passwordContainer = parameter as IHavePassword; if (passwordContainer != null) { var secureString = passwordContainer.Password; PasswordInVM = ConvertToUnsecureString(secureString); } //int count = 2; int count = dao.LoginAuthenticate(_UserName, _PasswordInVM); if (count == 1) { if (LoginServices != null) { LoginServices.LoginOk(); } } else { if (LoginServices != null) { LoginServices.LoginErrado(); } } }
//put an existing login object private async Task <bool> PutLoginAsync(string username) { var loginServices = new LoginServices(); var response = await loginServices.PutLogin(recordedlogin.user_id, logindetails); return(response); }
TokenResponseModel BunchyAuth(string access_token_return, string provider) { LoginServices loginservices = new LoginServices(); _TokenResponse = loginservices.LoginExternal(access_token_return, provider); return(_TokenResponse); }
// GET: DeptRep public ActionResult Index(string sessionId) { ViewData["SessionId"] = sessionId; ViewData["USER"] = LoginServices.GetUserBySessionId(sessionId); return(View()); }
protected void Session_End(object sender, EventArgs e) { try { if (Functions.CheckSession(Session["loginid"], "string")) { LoginServices service = new LoginServices(); service.LogoutHistory(Session["loginid"].ToString(), Session["sessionid"].ToString()); //set thuoc tinh de xoa thu muc trong sessiong end PropertyInfo p = typeof(System.Web.HttpRuntime).GetProperty("FileChangesMonitor", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Static); object o = p.GetValue(null, null); FieldInfo f = o.GetType().GetField("_dirMonSubdirs", BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.IgnoreCase); object monitor = f.GetValue(o); MethodInfo m = monitor.GetType().GetMethod("StopMonitoring", BindingFlags.Instance | BindingFlags.NonPublic); m.Invoke(monitor, new object[] { }); //delete folder DirectoryInfo dirRemove = new DirectoryInfo(string.Format("{0}/Profiles/{1}/Temps/{2}_{3}", Application["dirCache"], EncDec.Encrypt(Session["loginid"].ToString()), Session["userid"].ToString(), Session.SessionID)); if (dirRemove.Exists) { dirRemove.Delete(true); } } } catch (Exception ex) { Log4Net logger = new Log4Net("Global"); logger.Error(ex); } }
public void GetPreLoginElectionData_ShouldReturnAValid_RetrievedPageDataModel() { // Arrange // because the LoginServices class requires an instance of the // IElectionsRepository var mockElectionsRepo = new Mock <IElectionsRepository>(); mockElectionsRepo.Setup(x => x.GetById(It.IsAny <int>())) .Returns <int>(electionId => { var newElection = new Election { Id = electionId, OpenDate = ExpectedOpenDate, CloseDate = ExpectedCloseDate, LoginScreenOpenMessage = ExpectedLoginScreenOpenMessage, LoginScreenCloseMessage = ExpectedLoginScreenCloseMessage, LoginIdLabelTxt = ExpectedLoginIdLabelTxt, LoginPinLabelTxt = ExpectedLoginPinLabelTxt, LandingPageTitle = ExpectedLandingPageTitle, LandingPageMessage = ExpectedLandingPageMessage }; return(newElection); }); var mockVotersRepo = new Mock <IVotersRepository>(); Expression <Func <Voter, bool> > testExpression = expr => (expr.LoginId == "22222222"); mockVotersRepo.Setup(x => x.Get(It.Is <Expression <Func <Voter, bool> > >( criteria => Lambda.Eq(criteria, testExpression)))) .Returns <Voter>(voter => { var newVoter = new Voter { LoginId = voter.LoginId, LoginPin = "1234" }; return(newVoter); }); var loginServices = new LoginServices( mockElectionsRepo.Object, mockVotersRepo.Object); // Act var result = loginServices.GetPreLoginElectionData(1); // Assert Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(RetrievedPageDataModel)); Assert.AreEqual(ExpectedOpenDate, result.OpenDate); Assert.AreEqual(ExpectedCloseDate, result.CloseDate); Assert.AreEqual(ExpectedLoginScreenOpenMessage, result.LoginScreenOpenMessage); Assert.AreEqual(ExpectedLoginScreenCloseMessage, result.LoginScreenCloseMessage); Assert.AreEqual(ExpectedLoginIdLabelTxt, result.LoginIdLabelTxt); Assert.AreEqual(ExpectedLoginPinLabelTxt, result.LoginPinLabelTxt); Assert.AreEqual(ExpectedLandingPageTitle, result.LandingPageTitle); Assert.AreEqual(ExpectedLandingPageMessage, result.LandingPageMessage); }
public ActionResult GenFormLogin(string userName, string password) { ILoginServices loginServices = new LoginServices(); LoginUser user = LoginUser.NewLoginUser(userName, password); loginServices.Login(user); if (loginServices.IsLoggedIn(user)) { DateTime expires = DateTime.Now.AddHours(1); var loginCookie = new HttpCookie("loginCookie", ApplicationContext.User.Identity.Name); Session["user"] = ApplicationContext.User; loginCookie.Expires = expires; Response.AppendCookie(loginCookie); } return(this.Direct(new { success = loginServices.IsLoggedIn(user), data = new { user = user.UserName, password = user.Password } })); }
public FunctionalTest() { _UserService = new UserServices(_session); _AdminService = new AdminServices(_session); _LoginService = new LoginServices(_session); _BankServices = new BankServices(_session); }
public void SimpleLoginOk() { LoginServices login = new LoginServices(userRepo, teamRepo); login.CreateSession("sSanchez", "user"); Assert.AreEqual("sSanchez", login.LoggedUser.UserName); }
public JsonResult Logon(string username, string password, bool rememberMe) { AccountModel oResult = new AccountModel(); try { if (ModelState.IsValid) { using (var svc = new LoginServices()) { oResult = svc.GetSignInUser(username, password); if (oResult.Exception.ErrorCode == 0) { IdentitySignin(oResult, null, rememberMe); } } } } catch (Exception ex) { oResult.Exception = oException.Set(ex); } return(Json(oResult, JsonRequestBehavior.AllowGet)); }
public ActionResult ChangePassword(String userName, String currentPassword, String newPassword) { var user = GetUser(userName, currentPassword); LoginServices.ChangePassword(user, newPassword); return(this.Direct(new { success = LoginServices.CheckPassword(newPassword) })); }
public ActionResult Login([Required] string username, [Required] string password) { ILoginServices login = new LoginServices(); var viewModel = new WeatherViewModel(); bool logged = login.UserLogin(username, password); if (logged) { viewModel.isLogged = true; viewModel.countryList = CountrySelectList(); List <SelectListItem> citiesSelectList = new List <SelectListItem>(); var citySelectList = new SelectList(citiesSelectList, "Value", "Text"); viewModel.cityList = citySelectList; var weatherConditions = GetWeatherConditions(1); viewModel.weatherConditions = weatherConditions; viewModel.username = username; } return(View("Index", viewModel)); }
//get a login object public async Task <Login> getLogin(string username) { var loginServices = new LoginServices(); var result = await loginServices.GetLogin(username); return(result); }
private void confirmbutton_Click(object sender, EventArgs e) { logs = new LoginServices(); int result = logs.Validation(loginidtextBox.Text, textBox1.Text); if (result != 0) { if (textBox2.Text == textBox3.Text) { ls = new LoginServices(); int r = ls.Updatepass(loginidtextBox.Text, textBox2.Text); if (r > 0) { MessageBox.Show("Password changed.. Login Again"); logInForm log = new logInForm(); log.Show(); this.Hide(); } else { MessageBox.Show("Error"); } } else { MessageBox.Show("Password is not matched"); } } else { MessageBox.Show("User id or password are wrong"); } }
public void RecoverAllFollowedTeams() { ILoginServices loginServices = new LoginServices(userRepo, teamRepo); IUserServices userServices = new UserServices(loginServices, userRepo, teamRepo, sportRepo); ITeamServices teamServices = new TeamServices(loginServices, teamRepo, sportRepo, userRepo); ISportServices sportServices = new SportServices(loginServices, sportRepo); loginServices.CreateSession("sSanchez", "user"); TeamDTO cavaliers = new TeamDTO() { Name = "Cavaliers", Logo = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))), SportName = "Baskteball" }; SportDTO basketball = new SportDTO() { Name = "Baskteball" }; TeamDTO team = new TeamDTO() { Name = "Cavaliers", Logo = EncondeImage(Image.FromFile(GetResourcePath("Cavaliers.jpg"))), SportName = "Baskteball" }; sportServices.CreateSport(basketball); teamServices.CreateTeam(team); teamServices.AddFollowedTeam("Cavaliers_Baskteball"); IEnumerable <TeamDTO> followedTeams = userServices.GetFollowedTeams(); Assert.AreEqual(cavaliers.Name, followedTeams.First().Name); }