public async Task <ActionResult> LogOff() { using (var client = new HttpClient()) { client.BaseAddress = new Uri(Baseurl); LoginDetailsModel ld = new LoginDetailsModel(); ld.ID = ((AccountModel)Session["acct"]).Id; ld.userId = ((AccountModel)Session["acct"]).uId; ld.loginDate = DateTime.Now; ld.logoutDate = DateTime.Now; ld.userType = ((AccountModel)Session["acct"]).userType; var ldtls = JsonConvert.SerializeObject(ld); HttpResponseMessage Res1 = await client.PutAsync("api/logindetails/update", new StringContent(ldtls, Encoding.UTF8, "application/json")); if (Res1.IsSuccessStatusCode) { FormsAuthentication.SignOut(); Session.Abandon(); Session.Clear(); Session.RemoveAll(); return(RedirectToAction("Index", "Account")); } return(Redirect(Request.UrlReferrer.PathAndQuery)); } }
public ActionResult Login(LoginDetailsModel loginDetailsModel) { if (ModelState.IsValid) { // do validation IUserBasic userBasic = null; ValidateUserStatus status = InstanceContainer.TicketManager.LogUserIn( this.RequestContextData.ApplicationThemeInfo.ApplicationId , loginDetailsModel.UserName , loginDetailsModel.Password , loginDetailsModel.RememberMe , out userBasic); if (status == ValidateUserStatus.Valid) { Response.Redirect(System.Web.Security.FormsAuthentication.GetRedirectUrl(userBasic.UserName, false)); return(null); } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(View(loginDetailsModel)); }
public IActionResult Index(LoginDetailsModel loginDetailsModel) { List <LoginCredentials> userDetail = dataBaseOperations.GetCredentials(); LoginCredentials user = userDetail.Where(x => x.UserID == loginDetailsModel.UserID && x.Password == loginDetailsModel.Password).FirstOrDefault(); if (user != null) { return(RedirectToAction("Dashboard", "Login", user)); } return(RedirectToAction("Index")); }
public ActionResult LoginDetails(string Username) { LoginDetailsModel model = new LoginDetailsModel(); var mongo = GetMongoDb(); IMongoCollection <Login> collection = mongo.GetCollection <Login>("EventStore.Common.Login"); var results = collection.FindAsync(x => x.UserName == Username); results.Wait(); var docs = results.Result.ToListAsync(); docs.Wait(); DataManager <Login> dataManager = new DataManager <Login>(); var historyItems = dataManager.GetHistory(docs.Result.First()); model.Logins = historyItems.ToList(); model.Username = Username; return(View(model)); }
public async Task <ActionResult> Login(AccountModel accountmodel) { try { if (ModelState.IsValid) { if (accountmodel.userName != null && accountmodel.password != null) { using (var client = new HttpClient()) { //Passing service base url client.BaseAddress = new Uri(Baseurl); client.DefaultRequestHeaders.Clear(); //Define request data format client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); //Sending request to find web api REST service resource GetAllEmployees using HttpClient HttpResponseMessage Res = await client.GetAsync("api/Account/Get/" + accountmodel.userName.Trim() + "/" + accountmodel.password.Trim()); //Checking the response is successful or not which is sent using HttpClient if (Res.IsSuccessStatusCode) { //Storing the response details recieved from web api var EmpResponse = Res.Content.ReadAsStringAsync().Result; AccountModel acct = new AccountModel(); acct = JsonConvert.DeserializeObject <AccountModel>(EmpResponse); if (acct.Id > 0) { //Get Role based Menu Details HttpResponseMessage menuRes = await client.GetAsync("api/Menu/Get/" + acct.roleId + "/ G"); //Checking the response is successful or not which is sent using HttpClient if (menuRes.IsSuccessStatusCode) { var menuResponse = menuRes.Content.ReadAsStringAsync().Result; List <MenuModel> md = new List <MenuModel>(); md = JsonConvert.DeserializeObject <List <MenuModel> >(menuResponse); //Insert Records into Login Details LoginDetailsModel ld = new LoginDetailsModel(); ld.userId = acct.uId; ld.loginDate = DateTime.Now; ld.logoutDate = DateTime.Now; ld.userType = acct.userType; var ldtls = JsonConvert.SerializeObject(ld); HttpResponseMessage Res1 = await client.PostAsync("api/logindetails/insert", new StringContent(ldtls, Encoding.UTF8, "application/json")); //Checking the response is successful or not which is sent using HttpClient if (Res1.IsSuccessStatusCode) { if (md.Count > 0) { FormsAuthentication.SetAuthCookie(acct.userName, false); // set the formauthentication cookie Session["acct"] = acct; // Bind the account details to "LoginCredentials" session Session["MenuDetails"] = md; //Bind the _menus list to MenuMaster session Session["UserName"] = acct.userName; return(View("Home")); } else { ModelState.AddModelError("", "User rights not assigned"); return(View("Index")); } } } } } } } ModelState.AddModelError("", "Invalid username or password"); return(View("Index")); } return(View("Index")); } catch (Exception ex) { ExceptionLogHandler.LogData(ex); throw ex; } }
public bool Login(LoginDetailsModel logins) { var rows = ExecuteModel <int>("", logins, ConString); return((rows > 0) ? true : false); }
public bool Login(LoginDetailsModel logins) { }