public LoginVerification VerifyLogin(string username, string password) { LoginVerification result = LoginVerification.INCORRECT_USERNAME; using (DataSet dsLoginAuthentication = DAL.Login.VerifyLoginDetails(username, password)) { if ((dsLoginAuthentication != null) && (dsLoginAuthentication.Tables.Count > 0) && (dsLoginAuthentication.Tables[0].Rows.Count > 0)) { switch (Convert.ToInt32(dsLoginAuthentication.Tables[0].Rows[0][0])) { case -2: result = LoginVerification.INCORRECT_PASSWORD; break; case -1: result = LoginVerification.INCORRECT_USERNAME; break; case 1: result = LoginVerification.LOGIN_VERIFIED; break; } } } return(result); }
public ResultViewModel Verify(LoginVerification verification) { if (verification == null) { throw new HttpResponseException(Request.CreateResponse( HttpStatusCode.BadRequest, "Missing required parameters")); } Uri link = new Uri(verification.VerificationLink); NameValueCollection linkQueryParams = HttpUtility.ParseQueryString(link.Query); if (linkQueryParams["code"] == null) { throw new HttpResponseException(Request.CreateResponse( HttpStatusCode.BadRequest, "Invalid verification link")); } FxSyncNet.SyncClient syncClient = new FxSyncNet.SyncClient(); try { syncClient.VerifyLogin(verification.UID, linkQueryParams["code"]); } catch (Exception ex) { throw new HttpResponseException(Request.CreateResponse( HttpStatusCode.BadRequest, Utility.GetExceptionMessage(ex))); } return(new ResultViewModel()); }
public async Task <IActionResult> Login(LoginVerification user) { TempData["aadhar"] = user.AadhaarNo; string token; using (var httpclient = new HttpClient()) { httpclient.BaseAddress = new Uri("https://localhost:44316/"); var postData = httpclient.PostAsJsonAsync <LoginVerification>("/api/Authentication/VerifyUser", user); var res = postData.Result; if (res.IsSuccessStatusCode) { token = await res.Content.ReadAsStringAsync(); TempData["token"] = token; if (token == "Yes") { return(RedirectToAction("CheckPassword")); } if (token == "No") { return(RedirectToAction("NewPassword")); } } } return(View()); }
private void btnUpdatePassword_Click(object sender, EventArgs e) { var name = this.txtUsername.Text; var oldPass = this.txtOldPassword.Text; var newPass = this.txtNewPassword.Text; var newPassCheck = this.txtConfirmNewPassword.Text; if (newPass.Equals(newPassCheck)) { bool check = LoginVerification.UpdatePassword(name, oldPass, newPass); if (check) { MessageBox.Show("Password Updated"); UserLoginInfo.Password = newPass; } else { MessageBox.Show("Invalid"); } } else { MessageBox.Show("New Password doesn't match"); } }
public static User VerifyUser(string userName, string password, out LoginVerification verifyLogin) { User user = null; verifyLogin = LoginVerification.LOGIN_VERIFIED; using (DataSet dsUserDetails = DAL.User.VerifyUser(userName, password)) { if ((dsUserDetails != null) && (dsUserDetails.Tables.Count > 0) && (dsUserDetails.Tables[0].Rows.Count > 0)) { switch (Convert.ToInt32(dsUserDetails.Tables[0].Rows[0][0])) { case -2: verifyLogin = LoginVerification.INCORRECT_PASSWORD; break; case -1: verifyLogin = LoginVerification.INCORRECT_USERNAME; break; case 1: verifyLogin = LoginVerification.LOGIN_VERIFIED; user = new User(dsUserDetails.Tables[0].Rows[0]["Name"].ToString(), userName); break; } } } return(user); }
public static User VerifyUser(string userName, string password, out LoginVerification verifyLogin) { User user = null; verifyLogin = LoginVerification.LOGIN_VERIFIED; using (DataSet dsUserDetails = DAL.User.VerifyUser(userName, password)) { if ((dsUserDetails != null) && (dsUserDetails.Tables.Count > 0) && (dsUserDetails.Tables[0].Rows.Count > 0)) { switch (Convert.ToInt32(dsUserDetails.Tables[0].Rows[0][0])) { case -2: verifyLogin = LoginVerification.INCORRECT_PASSWORD; break; case -1: verifyLogin = LoginVerification.INCORRECT_USERNAME; break; case 1: verifyLogin = LoginVerification.LOGIN_VERIFIED; user = new User(dsUserDetails.Tables[0].Rows[0]["Name"].ToString(), userName); break; } } } return user; }
public async Task <ActionResult> VerifyLogin(LoginInfo info) { //we will be receiving Content-Type = application/x-www-form-urlencoded //https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/sending-html-form-data-part-1 //https://www.exceptionnotfound.net/asp-net-mvc-demystified-modelstate/ if (ModelState.IsValid && !string.IsNullOrEmpty(info.dealerid) && !string.IsNullOrEmpty(info.password)) { string url = $"{VDA_API_URL}/VerifyLogin?username={Uri.EscapeDataString(info.dealerid)}&password={Uri.EscapeDataString(info.password)}"; var client = new HttpClient(); client.DefaultRequestHeaders.Accept.Clear(); //add any default headers below this client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(url); string json_string = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK) { LoginVerification login_credentials = JsonConvert.DeserializeObject <LoginVerification>(json_string); if (login_credentials.validUser) { HttpContext.Session.SetString(SessionKeyDealerName, login_credentials.dealer_name); HttpContext.Session.SetString(SessionKeyUsername, login_credentials.username); HttpContext.Session.SetString(SessionKeyFirstName, login_credentials.first_name); HttpContext.Session.SetString(SessionKeyLastName, login_credentials.last_name); HttpContext.Session.SetString(SessionKeyPassword, info.password); return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Login", "Home", new { error = true })); } } else { return(RedirectToAction("Login", "Home", new { error = true })); } } else { return(RedirectToAction("Login", "Home", new { error = true })); } }
public ActionResult Login(LoginModel model, string returnUrl) { try { var organizationID = OrganizationUtility.GetOrganizationID(Request.Url.AbsoluteUri); if (ModelState.IsValid && organizationID != null) { if (LoginVerification.ValidateUser(model.UserName, model.Password, (int)organizationID)) { FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe); if (SessionManagement.UserInfo.LogAccountType == LoginAccountType.LiveAccount) { return(RedirectToAction("Index", "Dashboard")); } //If Introducing Broker else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_IB) { return(RedirectToAction("Index", "Dashboard", new { Area = "IntroducingBroker" })); } //If Asset Manager else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_AM) { return(RedirectToAction("Index", "Profile", new { Area = "AssetManager" })); } //If Super Admin else if (SessionManagement.UserInfo.AccountCode == Constants.K_ACCTCODE_SUPERADMIN) { return(RedirectToAction("Index", "Dashboard", new { Area = "SuperAdmin" })); } else { ModelState.AddModelError("", "Some error occurred!"); } } else { ModelState.AddModelError("", "The user name or password provided is incorrect."); } } return(View(model)); } catch (Exception ex) { CurrentDeskLog.Error(ex.Message, ex); throw; } }
private void btnLogin_Click(object sender, EventArgs e) { if (LoginVerification.Verification(txtUsername.Text, txtPassword.Text)) { MessageBox.Show("Login Successful"); RequestForm rf = new RequestForm(); rf.Show(); this.Hide(); } else { MessageBox.Show("Login Failed"); } }
public IActionResult Login(LoginViewModel model) { if (!ModelState.IsValid) { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View("Index", model)); } LoginVerification loginVerify = new LoginVerification(db, HttpContext.Session); String UserType = loginVerify.getUserType(model); if (UserType == "Warehouse Manager") { return(RedirectToAction("Index", "Warehouse")); } else if (UserType == "Admin") { return(RedirectToAction("Index", "Admin")); } else if (UserType == "Shopkeeper") { return(RedirectToAction("Index", "Shop")); } else if (UserType == "Stitching Unit Manager") { return(RedirectToAction("Index", "StitchingUnitManager")); } else if (UserType == "Stitching Unit Department Head") { return(RedirectToAction("Index", "StitchingUnitDepartmentHead")); } else if (UserType == "Customer") { return(RedirectToAction("Index", "Customer")); } else { ModelState.AddModelError(string.Empty, "Invalid login attempt."); return(View("Index", model)); } }
public JsonResult VerifyLoginDetails(string loginName, string password) { BAL.Login login = new Login(); LoginVerification verified = LoginVerification.LOGIN_VERIFIED; BAL.User user = BAL.User.VerifyUser(loginName, password, out verified); if (verified == LoginVerification.LOGIN_VERIFIED) { Session["UserName"] = user.Name; Session["User"] = user; } return(Json(new { success = true, loginAuthentication = verified })); }
private void btnCreate_Click(object sender, EventArgs e) { CheckIfValuePresentInTextField(); int empId = Convert.ToInt32(this.txtEmployeeID.Text); string username = this.txtUsername.Text; string password = this.txtPassword.Text; string designation = this.txtDesignation.Text; try { LoginVerification.CreateLogin(username, password, designation, empId); MessageBox.Show("Account created"); this.PopulateEmpTable(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
private void btnDelete_Click(object sender, EventArgs e) { PersonRepo p1 = new PersonRepo(); p1.PersonID = Convert.ToInt32(this.txtPID.Text); DoctorRepo dr = new DoctorRepo(); if (this.txtDoctorId.Text != "" && this.txtDoctorId.Text != null) { dr.DoctorID = Convert.ToInt32(this.txtDoctorId.Text); } EmployeeRepo er = new EmployeeRepo(); er.EmpID = Convert.ToInt32(this.txtEmpId.Text); try { if (this.cmbDesignation.Text == "Doctor") { // IF DOCTOR -> Delete from all table that contains doctor's reference first CancelledAppointmentsRepo.RemoveParticularDoctorsAppointments(dr.DoctorID); AppointmentRepo.RemoveParticularDoctorsAppointments(dr.DoctorID); PatientDiseaseRepo.DeleteInfoBasedOnDoctor(dr.DoctorID); LoginVerification.DeleteLoginInfo(er.EmpID); // Afterwards delete from doctor table dr.DeleteDoctor(dr.DoctorID); } int empdelete = er.DeleteEmployee(er.EmpID); int persondeleted = p1.DeletePerson(p1.PersonID); this.PopulatePersonTable(); MessageBox.Show("Successfully deleted!"); this.ClearAll(); } catch (Exception exc) { MessageBox.Show("error!" + exc); } }
private void btnLogin_Click(object sender, EventArgs e) { this.sqlConnection = DataAccess.Sqlcon; bool credentialsMatched = LoginVerification.VerifyLogin(this.txtUsername.Text, this.txtPassword.Text); if (credentialsMatched) { //this.Visible = false; // Hide Login Window switch (UserLoginInfo.Designation) { case "Manager": { this.txtUsername.Text = string.Empty; this.txtPassword.Text = string.Empty; this.Visible = false; new ManagerForm().Visible = true; break; } case "Doctor": { this.txtUsername.Text = string.Empty; this.txtPassword.Text = string.Empty; this.Visible = false; new DoctorForm().Visible = true; break; } case "Receptionist": { this.txtUsername.Text = string.Empty; this.txtPassword.Text = string.Empty; this.Visible = false; new ReceptionistForm().Visible = true; break; } default: break; } } }
private void btnCreate_Click(object sender, EventArgs e) { CheckIfValuePresentInTextField(); int empId = Convert.ToInt32(this.txtEmployeeID.Text); string username = this.txtUsername.Text; string password = this.txtPassword.Text; string designation = this.txtDesignation.Text; try { bool result = LoginVerification.CheckIfLoginCredAvailableForEmp(empId); if (result) { throw new Exception("Employee already has login credentials"); } LoginVerification.CreateLogin(username, password, designation, empId); MessageBox.Show("Account created"); this.PopulateEmpTable(); } catch (Exception exc) { MessageBox.Show(exc.Message); } }
static void Main(string[] args) { Console.WriteLine(LoginVerification.IsLoggedIn); LoginVerification.Logging(); Console.WriteLine(LoginVerification.IsLoggedIn); }
//display KPI results page public async Task <ActionResult> KPI(string search) { List <Intent> intent_list = new List <Intent> { new Intent() { Id = 1, Name = "Dealer Share", Utterance = search }, new Intent() { Id = 1, Name = "Dealer Effectiveness", Utterance = search }, new Intent() { Id = 1, Name = "Dealer Sales", Utterance = search }, new Intent() { Id = 1, Name = "Insell", Utterance = search }, new Intent() { Id = 1, Name = "None", Utterance = search } }; ViewBag.SelectedValue = "None"; ViewBag.ListOfIntents = intent_list; ViewBag.search = search; //get the most related kpi string dealer_name = HttpContext.Session.GetString(SessionKeyDealerName); string username = HttpContext.Session.GetString(SessionKeyUsername); string password = HttpContext.Session.GetString(SessionKeyPassword); ViewBag.dealer_name = dealer_name; //check if admin string login_url = $"{VDA_API_URL}/VerifyLogin?username={Uri.EscapeDataString(username)}&password={Uri.EscapeDataString(password)}"; var credentials_client = new HttpClient(); credentials_client.DefaultRequestHeaders.Accept.Clear(); //add any default headers below this credentials_client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage credentials_response = await credentials_client.GetAsync(login_url); ViewBag.IsAdmin = false; if (credentials_response.StatusCode == HttpStatusCode.OK) { string json_string = await credentials_response.Content.ReadAsStringAsync(); LoginVerification login = JsonConvert.DeserializeObject <LoginVerification>(json_string); ViewBag.IsAdmin = login.isAdmin; } // do related kpi string related_kpi_url = $"{VDA_API_URL}/RelatedKpi?query={search}&dealer_name={dealer_name}"; var related_kpi_client = new HttpClient(); related_kpi_client.DefaultRequestHeaders.Accept.Clear(); //add any default headers below this related_kpi_client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage related_kpi_response = await related_kpi_client.GetAsync(related_kpi_url); if (related_kpi_response.StatusCode == HttpStatusCode.OK) { string json_string = await related_kpi_response.Content.ReadAsStringAsync(); Kpi most_related_kpi = JsonConvert.DeserializeObject <Kpi>(json_string); ViewBag.most_related_kpi = most_related_kpi; } // call web api to get action sending it kpi information List <Kpi> most_needed_kpis = new List <Kpi>(); string needed_kpi_url = $"{VDA_API_URL}/NeededKpi?dealer_name={Uri.EscapeDataString(dealer_name)}"; var needed_kpi_client = new HttpClient(); needed_kpi_client.DefaultRequestHeaders.Accept.Clear(); //add any default headers below this needed_kpi_client.DefaultRequestHeaders.Accept.Add( new MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage needed_kpi_response = await needed_kpi_client.GetAsync(needed_kpi_url); if (needed_kpi_response.StatusCode == HttpStatusCode.OK) { string json_string = await needed_kpi_response.Content.ReadAsStringAsync(); most_needed_kpis = JsonConvert.DeserializeObject <List <Kpi> >(json_string); ViewBag.needed_kpi_list = most_needed_kpis; } return(View()); }
protected void btnLogin_Click(object sender, EventArgs e) { LoginVerification logVer = new LoginVerification(); bool sesscue = logVer.Login(txtname.Value.Trim(), EntityUtils.StringToMD5(txtpass.Value.Trim(), 16)); if (!sesscue) { lbltxt.Text = "温馨提示:您的用户名或密码错误!"; //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('用户名或密码错误!')</script>"); return; } else { DataTable dt = logVer.loginmanige(txtname.Value.Trim(), EntityUtils.StringToMD5(txtpass.Value.Trim(), 16)); if (dt.Rows.Count > 0) { if (dt.Rows[0]["oCheck"].ToString() == "False") { lbltxt.Text = "温馨提示:该用户未通过审核!"; //ClientScript.RegisterStartupScript(GetType(), "", "<script>alert('用户未通过审核!')</script>"); return; } DataTable dtt = logVer.GetnIDcID(); Session.Add("AdminName", txtname.Value.Trim()); Session.Add("aid", dt.Rows[0]["nID"].ToString()); Session.Add("anid", dtt.Rows[0]["nID"].ToString()); //nID Session.Add("acid", dtt.Rows[0]["cid"].ToString()); //cid Session.Add("LastTime", dt.Rows[0]["dtLastTime"].ToString()); Session.Timeout = 600; logVer.updatelogin(txtname.Value.Trim(), EntityUtils.StringToMD5(txtpass.Value.Trim(), 16)); if (ckb.Checked) { //将界面的值写入cookies HttpCookie cookie = new HttpCookie("AdminName"); cookie.Value = txtname.Value.Trim(); cookie.Expires = DateTime.Now.AddDays(14); HttpCookie cookie1 = new HttpCookie("AdminPass"); cookie1.Value = txtpass.Value.Trim(); cookie1.Expires = DateTime.Now.AddDays(14); HttpCookie cookie2 = new HttpCookie("RememberMe"); cookie2.Value = "1"; cookie2.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); Response.Cookies.Add(cookie1); Response.Cookies.Add(cookie2); } else { //将空值写入cookies HttpCookie cookie = new HttpCookie("AdminName"); cookie.Value = ""; cookie.Expires = DateTime.Now.AddDays(14); HttpCookie cookie1 = new HttpCookie("AdminPass"); cookie1.Value = ""; cookie1.Expires = DateTime.Now.AddDays(14); HttpCookie cookie2 = new HttpCookie("RememberMe"); cookie2.Value = ""; cookie2.Expires = DateTime.Now.AddDays(14); Response.Cookies.Add(cookie); Response.Cookies.Add(cookie1); Response.Cookies.Add(cookie2); } Response.Redirect("Main/Main.aspx"); } else { Session.Contents.Clear(); } } }
/// <summary> /// Handles the protocol request. /// </summary> /// <param name="request">The instance requesting the protcol handle.</param> public void Handle(LoginRequest request) { request.Buffer.Skip(1); LoginVerification.Process(request, LoginConnectionType.NewConnection); }